Platform SDK: Windows Sockets |
The WPUQueueApc function queues a user mode–asynchronous procedure call (APC) to the specified thread in order to facilitate invocation of overlapped I/O completion routines.
int WPUQueueApc( LPWSATHREADID lpThreadId, LPWSAUSERAPC lpfnUserApc, DWORD dwContext, LPINT lpErrno );
If no error occurs, WPUQueueApc returns zero and queues the completion routine for the specified thread. Otherwise, it returns SOCKET_ERROR, and a specific error code is available in lpErrno.
This function queues an APC function against the specified thread. Under Win32, this will be done using a user mode–asynchronous procedure call (APC). The APC will only execute when the specified thread is blocked in an alertable wait. For Win16, a callback will be made directly. In Win16 environments, this call is safe for use within an interrupt context.
LPWSAUSERAPC is defined as follows:
typedef void ( CALLBACK FAR * LPWSAUSERAPC )( DWORD dwContext );
Because the APC mechanism supports only a single 32-bit context value, lpfnUserApc itself cannot be the client specified–completion routine, which involves more parameters. The service provider must instead supply a pointer to its own APC function that uses the supplied dwContext value to access the needed result information for the overlapped operation, and then invokes the client specified–completion routine.
For service providers where a user-mode component implements overlapped I/O, a typical usage of the APC mechanism is as follows:
Error code | Meaning |
---|---|
WSAEFAULT | The dwThreadId does not specify a valid thread. |
Version: Requires Windows Sockets 2.0.
Header: Declared in Ws2spi.h.