if no error occurs, closesocket returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.
Setting the l_onoff member of the linger structure to nonzero and the l_linger member with a nonzero timeout interval on a nonblocking socket is not recommended.
意思是,在非阻塞的Socket情况下不建议设置SO_LINGER参数。
In this case, the call toclosesocketwill fail with an error of WSAEWOULDBLOCKif the close operation cannot be completed immediately. If closesocketfails withWSAEWOULDBLOCK the socket handle is still valid, and a disconnect is not initiated. The application must call closesocket again to close the socket.
If the l_onoff member of the LINGER structure is zero on a stream socket, the closesocket call will return immediately and does not receive whether the socket is blocking or nonblocking. However, any data queued for transmission will be sent, if possible, before the underlying socket is closed.