WPUCompleteOverlappedRequest

The WPUCompleteOverlappedRequest function performs overlapped I/O completion notification for overlapped I/O operations.

WSAEVENT WPUCompleteOverlappedRequest (
  SOCKET s,                      
  LPWSAOVERLAPPED lpOverlapped,  
  DWORD dwError,                 
  DWORD cbTransferred,           
  LPINT lpErrno                 
);
 

Parameters

s
[in] Service provider socket created by WPUCreateSocketHandle.
lpOverlapped
[in] A pointer to a WSAOVERLAPPED structure associated with the overlapped I/O operation whose completion is to be notified.
dwError
[in] Completion status of the overlapped I/O operation whose completion is to be notified.
cbTransferred
[in] Number of bytes transferred to or from client buffers (the direction of the transfer depends on the send or receive nature of the overlapped I/O operation whose completion is to be notified).
lpErrno
[out] A pointer to the error code resulting from execution of this function.

Remarks

The WPUCompleteOverlappedRequest function performs overlapped I/O completion notification for overlapped I/O operations where the client-specified completion mechanism is something other than user mode Asynchronous Procedure Call (APC). This function can only be used for socket handles created by WPUCreateSocketHandle.

Note This function is different from other functions with the "WPU" prefix in that it is not accessed through the upcall table. Instead, it is exported directly by WS2_32.DLL. Service providers that need to call this function should link with WS2_32.LIB or use appropriate Operating System functions such as LoadLibrary() and GetProcAddress() to retrieve the function pointer.

The function WPUCompleteOverlappedRequest is used by service provider that do not implement Installable File System (IFS) functionality directly for the socket handles they expose. It performs completion notification for any overlapped I/O request for which the specified completion notification is other than a user-mode APC. WPUCompleteOverlappedRequest is supported only for the socket handles created by WPUCreateSocketHandle and not for sockets created by a service provider directly.

If the client selects a user-mode APC as the notification method, the service provider should use WPUQueueApc or an other appropriate operating system function to perform the completion notification. If user-mode APC is not selected by the client, a service provider that does not implement IFS functionality directly cannot determine whether or not the client has associated a completion port with the socket handle. Thus it cannot determine whether the completion notification method should be queuing a completion status record to a completion port or signaling an event found in the WSAOVERLAPPED structure. The Windows Socket 2 architecture keeps track of any completion port association with a socket created by WPUCreateSocketHandle and can make a correct decision between completion port based notification or event based notification.

When WPUCompleteOverlappedRequest queues a completion indication, it sets the InternalHigh member of the WSAOVERLAPPED structure to the count of bytes transferred. Then it sets the Internal member to some OS-dependent value other than the special value WSS_OPERATION_IN_PROGRESS. There may be some slight delay after WPUCompleteOverlappedRequest returns before these values appear, since processing may occur asynchronously. However, the InternalHigh value (byte count) is guaranteed to be set by the time Internal is set.

WPUCompleteOverlappedRequest is available both on Windows 95 and Windows NT. It works as stated (performs the completion notification as requested by the client) whether or not the socket handle has been associated with a completion port.

Interaction with WSPGetOverlappedResult

The behavior of WPUCompleteOverlappedRequest places some constraints on how a service provider implements WSPGetOverlappedResult since only the Offset and OffsetHigh members of the WSAOVERLAPPED structure are exclusively controlled by the service provider, yet three values (byte count, flags, and error) must be retrieved from the structure by WSPGetOverlappedResult. A service provider may accomplish this any way it chooses as long as it interacts with the behavior of WPUCompleteOverlappedRequest properly. However, a typical implementation is as follows:

Return Values

If no error occurs, WPUCompleteOverlappedRequest returns 0 and notifies completion of the overlapped I/O operation according to the mechanism selected by the client (signals an event found in the WSAOVERLAPPED structure referenced by lpOverlapped and/or queues a completion status report to the completion port associated with the socket if a completion port is associated). Otherwise, WPUCompleteOverlappedRequest returns SOCKET_ERROR, and a specific error code is available in lpErrno.

Error Codes

WSAEINVAL The socket s is not a socket created by WPUCreateSocketHandle.

See Also

WSPGetOverlappedResult, WPUCreateSocketHandle, WPUQueueApc