| iMatix home page | << | < | > | >> |
![]() Version 1.91 |
#include "sflsock.h" int close_socket ( sock_t handle /* Socket handle */ )
Closes the socket. On UNIX, VMS, OS/2 calls the standard close function; some other systems have particular ways of accessing sockets. If there is an error on the close this function returns SOCKET_ERROR. You can handle errors (in sockerrno) as fatal except for EAGAIN which indicates that the operation would cause a non-blocking socket to block. Treat EWOULDBLOCK as EAGAIN.
{ #if (defined (DOES_SOCKETS)) if (!socket is alive (handle)) return (0); shutdown ((SOCKET) handle, 2); /* Shut socket gracefully */ # if (defined (__UNIX__) || defined (__VMS__) || defined (__OS2__)) return (close ((SOCKET) handle)); # elif (defined (__WINDOWS__)) { int rc; rc = closesocket ((SOCKET) handle); return (win_error (rc)); } # else # error "No code for function body." # endif #elif (defined (FAKE_SOCKETS)) return (0); /* Okay, closed */ #else return ((int) SOCKET_ERROR); /* Sockets not supported */ #endif }
| << | < | > | >> |
![]() |