|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#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 (defined (__UNIX__) || defined (__VMS__) || defined (__OS2__))
if (!socket is alive (handle))
return (0);
ip_sockets--;
shutdown (handle, 2);
return (close ((SOCKET) handle));
# elif (defined (__WINDOWS__))
int
rc;
if (!socket is alive (handle))
return (0);
ip_sockets--;
shutdown ((SOCKET) handle, 2);
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
}
| | << | < | > | >> |
|