Platform SDK: Windows Sockets

WSPRecvDisconnect

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

int WSPRecvDisconnect (
  SOCKET      s,                           
  LPWSABUF    lpInboundDisconnectData,   
  LPINT       lpErrno                       
);

Parameters

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 Values

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

Remarks

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.

Error Codes

Error code Meaning
WSAENETDOWN Network subsystem has failed.
WSAEFAULT Buffer referenced by the parameter lpInboundDisconnectData is too small.
WSAENOPROTOOPT Disconnect data is not supported by the indicated protocol family.
WSAEINPROGRESS Blocking Windows Sockets call is in progress, or the service provider is still processing a callback function.
WSAENOTCONN Socket is not connected (connection-oriented sockets only).
WSAENOTSOCK Descriptor is not a socket.

Requirements

  Version: Requires Windows Sockets 2.0.
  Header: Declared in Ws2spi.h.

See Also

WSPConnect, WSPSocket