| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

close_socket

#include "sflsock.h"
int
close_socket (
    sock_t handle                       /*  Socket handle                    */
)

Synopsis

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.

Source Code - (sflsock.c)

{
#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
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation