WSPCleanup function
WSPCleanup terminates use of the SAN service provider.
Syntax
int WSPCleanup(
_Out_ LPINT lpErrno
);
Parameters
- lpErrno [out]
Pointer to a variable that receives the error code.
Return value
Returns zero if successful; otherwise, returns SOCKET_ERROR and, in lpErrno, one of the following error codes:
Return code | Description |
---|---|
WSANOTINITIALISED | Successful WSPStartupEx call did not occur before the WSPCleanup call. |
WSAENETDOWN | Network subsystem failed. |
Note that a SAN service provider does not support the WSAEINVAL error code for WSPCleanup.
Remarks
The Windows Sockets switch must call a SAN service provider's WSPStartupEx function before it can start using that SAN service provider. After the switch no longer requires a SAN service provider, it calls the WSPCleanup function to terminate use of the SAN service provider and to allow the SAN service provider to release any resources that the SAN service provider allocated for operations requested by the switch.
The switch can call a SAN service provider's WSPStartupEx function more than once. For each WSPStartupEx call, the switch must issue a corresponding WSPCleanup call. The SAN service provider must keep an internal reference count of the number of its open instances. Calls to the SAN service provider's WSPCleanup function decrement this internal reference count. Only the final WSPCleanup call does the actual cleanup (that is, when the internal reference count reaches zero).
During cleanup, the SAN service provider releases resources that it previously allocated and cancels any pending calls or uncompleted asynchronous operations.
To cancel a pending call that the switch initiated or forwarded
A SAN service provider calls the WPUCompleteOverlappedRequest function to complete the overlapped operation that is related to that pending call.
In this call, the SAN service provider passes a pointer to a WSAOVERLAPPED structure for the overlapped operation, and also passes the WSA_OPERATION_ABORTED error code to specify that the overlapped operation was canceled.
Before calling the WPUCompleteOverlappedRequest function to cancel an overlapped operation, the SAN service provider should release any memory associated with that operation.
For more information about WPUCompleteOverlappedRequest, see the Microsoft Windows SDK documentation.
During cleanup, the SAN service provider does not signal event objects to post notification messages. For example, during cleanup, the SAN service provider does not post notification messages that indicate the arrival of an incoming connection (FD_ACCEPT) or the completion of a connection operation (FD_CONNECT).
Any sockets that are open during a final WSPCleanup call are reset and automatically released as if the WSPCloseSocket function was called.
A SAN service provider must ensure that its WSPCleanup function leaves the operating environment in a state in which the switch can immediately call the SAN service provider's WSPStartupEx function to reestablish usage.
Requirements
Target platform |
Desktop |
Version |
Requires Windows Sockets version 2.0. |
Header |
Ws2spi.h (include Ws2spi.h) |
See also