closesocket Function

C

int closesocket(
    SOCKET s
);

Description

The closesocket function closes an existing socket. This function releases the socket descriptor s. Any data buffered at the socket is discarded. If the socket s is no longer needed, closesocket() must be called in order to release all resources associated with s.

Preconditions

None.

Parameters

ParametersDescription
sSocket descriptor returned from a previous call to socket.

Returns

  • 0 - The function was successful.

  • SOCKET_ERROR (-1) - Function failed. errno is set accordingly.

Remarks

None.