The WSPCleanup function terminates use of the Windows Sockets service provider.
int WSPCleanup (
LPINT lpErrno
);
The Windows Sockets 2 SPI client is required to perform a successful WSPStartup call before it can use Windows Sockets service providers. When it has completed the use of Windows Sockets service providers, the SPI client will call WSPCleanup to deregister itself from a Windows Sockets service provider and allow the service provider to free any resources allocated on behalf of the Windows Sockets 2 client. It is permissible for SPI clients to make more than one WSPStartup call. For each WSPStartup call a corresponding WSPCleanup call will also be issued. Only the final WSPCleanup for the service provider does the actual cleanup; the preceding calls simply decrement an internal reference count in the Windows Sockets service provider.
When the internal reference count reaches zero and actual cleanup operations commence, any pending blocking or asynchronous calls issued by any thread in this process are canceled without posting any notification messages or signaling any event objects. Any pending overlapped send and receive operations (WSPSend/WSPSendTo/WSPRecv/WSPRecvFrom with an overlapped socket) issued by any thread in this process are also canceled without setting the event object or invoking the completion routine, if specified. In this case, the pending overlapped operations fail with the error status WSA_OPERATION_ABORTED. Any sockets open when WSPCleanup is called are reset and automatically deallocated as if WSPClosesocket was called; sockets which have been closed with WSPCloseSocket but which still have pending data to be sent are not affected—the pending data is still sent.
This function should not return until the service provider DLL is prepared to be unloaded from memory. In particular, any data remaining to be transmitted must either already have been sent or be queued for transmission by portions of the transport stack that will not be unloaded from memory along with the service provider's DLL.
The return value is zero if the operation has been successfully initiated. Otherwise, the value SOCKET_ERROR is returned, and a specific error number is available in lpErrno.
A Windows Sockets service provider must be prepared to deal with a process which terminates without invoking WSPCleanup (for example, as a result of an error). A Windows Sockets service provider must ensure that WSPCleanup leaves things in a state in which the WS2_32.DLL can immediately invoke WSPStartup to re-establish Windows Sockets usage.
WSANOTINITIALISED | A successful WSPStartup must occur before using this function. |
WSAENETDOWN | The network subsystem has failed. |
WSAEINVAL | The provider ID given to the name space provider is not managed by the name space provider. |
Windows NT: Yes
Windows: Yes
Windows CE: Unsupported.
Header: Declared in ws2spi.h.
WSPStartup, WSPClosesocket, WSPShutdown