The SockClose() call shuts down a socket and frees resources allocated to the socket.





is the descriptor of the socket to be closed.

If the SO_LINGER option of SockSetSockOpt() is enabled, any queued data is sent. If this option is disabled, any queued data is flushed.

Return values:

The value 0 indicates successful execution of the call. The value -1 indicates an error. You can get the specific error code by calling SockSock_Errno() or SockPSock_Errno(). Possible values are:


socket is not a valid socket descriptor.


The socket is in nonblocking mode. A previous connection attempt has not completed.

SockClose() is exactly the same as SockSoClose().

Note: SockClose() interfaces with the C function soclose() or, in the Windows environments, with closesocket().