Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function terminates use of the Windows Sockets service provider.
Syntax
int WSPCleanup( LPINT lpErrno ); |
Parameters
- lpErrno
-
[out] Pointer to the error code.
Return Value
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.
The following table shows the possible error codes.
Error value | Description |
---|---|
WSANOTINITIALISED |
A successful WSPStartupcall must occur before using this function. |
WSAENETDOWN |
Network subsystem has failed. |
WSAEINVAL |
Provider identifier given to the name-space provider is not managed by the name-space provider. |
Remarks
The Winsock SPI client is required to perform a successful WSPStartupcall before it can use Windows Sockets service providers. When it has completed the use of Windows Sockets service providers, the SPI client will call WSPCleanupto deregister itself from a Windows Sockets service provider and allow the service provider to free any resources allocated on behalf of the Winsock client. It is permissible for SPI clients to make more than one WSPStartupcall. For each WSPStartupcall, a corresponding WSPCleanupcall will also be issued. Only the final WSPCleanupfor 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, WSPRecvFromwith 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 WSPCleanupis called are reset and automatically deallocated as if WSPCloseSocketwas called; sockets that have been closed with WSPCloseSocketbut 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 notbe unloaded from memory along with the service provider's DLL.
A Windows Sockets service provider must be prepared to deal with a process that terminates without invoking WSPCleanup, for example, as a result of an error. A Windows Sockets service provider must ensure that WSPCleanupleaves things in a state in which the ws2.dll can immediately invoke WSPStartupto reestablish Windows Sockets usage.
Requirements
Header | ws2spi.h |
Library | Ws2.lib |
Windows Embedded CE | Windows CE .NET 4.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |