WSPRecvDisconnect function

The WSPRecvDisconnect function terminates reception on a socket and retrieves the disconnect data, if the socket is connection oriented.


int WSPRecvDisconnect(
  _In_  SOCKET   s,
  _Out_ LPWSABUF lpInboundDisconnectData,
  _Out_ LPINT    lpErrno


s [in]

Descriptor identifying a socket.

lpInboundDisconnectData [out]

Pointer to a buffer into which disconnect data is to be copied.

lpErrno [out]

Pointer to the error code.

Return value

If no error occurs, WSPRecvDisconnect returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code is available in lpErrno.

Error codeMeaning

The network subsystem has failed.


Buffer referenced by the parameter lpInboundDisconnectData is too small.


Disconnect data is not supported by the indicated protocol family.


Blocking Windows Sockets call is in progress, or the service provider is still processing a callback function.


Socket is not connected (connection-oriented sockets only).


The descriptor is not a socket.




WSPRecvDisconnect is used on connection-oriented sockets to disable reception, and retrieve any incoming disconnect data from the remote party.

After this function has been successfully issued, subsequent receives on the socket will be disallowed. This has no effect on the lower protocol layers. For TCP, the TCP window is not changed and incoming data will be accepted (but not acknowledged) until the window is exhausted. For UDP, incoming datagrams are accepted and queued. In no case will an ICMP error packet be generated.

To successfully receive incoming disconnect data, a Windows Sockets SPI client must use other mechanisms to determine that the circuit has been closed. For example, a client needs to receive an FD_CLOSE notification, or get a zero return value, or a WSAEDISCON error code from WSPRecv.

Note that WSPRecvDisconnect does not close the socket, and resources attached to the socket will not be freed until WSPCloseSocket is invoked.

Note  WSPRecvDisconnect does not block regardless of the SO_LINGER setting on the socket. A Windows Sockets SPI client should not rely on being able to reuse a socket after it has been WSPRecvDisconnected. In particular, a Windows Sockets provider is not required to support the use of WSPConnect on such a socket.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]



See also