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 returns the results of an overlapped operation on the specified socket.
Syntax
BOOL WSAGetOverlappedResult( SOCKET s, LPWSAOVERLAPPED lpOverlapped, LPDWORD lpcbTransfer, BOOL fWait, LPDWORD lpdwFlags ); |
Parameters
- s
-
[in] Descriptor identifying the socket. This is the same socket that was specified when the overlapped operation was started by a call to the WSARecv, WSARecvFrom, WSASend, WSASendTo, or WSAIoctlfunction.
- lpOverlapped
-
[in] Pointer to a WSAOVERLAPPEDstructure that was specified when the overlapped operation was started.
- lpcbTransfer
-
[out] Pointer to a 32-bit variable that receives the number of bytes that were actually transferred by a send or receive operation or by WSAIoctl.
- fWait
-
[in] Flag that specifies whether the function should wait for the pending overlapped operation to complete. If TRUE, the function does not return until the operation has been completed. If FALSE and the operation is still pending, the function returns FALSE and the WSAGetLastErrorfunction returns WSA_IO_INCOMPLETE. The fWaitparameter may be set to TRUE only if the overlapped operation selected the event-based completion notification.
- lpdwFlags
-
[out] Pointer to a 32-bit variable that will receive one or more flags that supplement the completion status. If the overlapped operation was initiated through WSARecvor WSARecvFrom, this parameter will contain the value for the lpFlagsparameter.
Return Value
If no error occurs, this function returns TRUE. This means that the overlapped operation has completed successfully and that the value pointed to by lpcbTransferhas been updated. If this function returns FALSE, this means that either the overlapped operation has not completed, the overlapped operation completed but with errors, or the overlapped operation's completion status could not be determined due to errors in one or more parameters to WSAGetOverlappedResult. On failure, the value pointed to by lpcbTransferwill not be updated. Use WSAGetLastErrorto determine the cause of the failure (either of WSAGetOverlappedResultor of the associated overlapped operation).
The following table shows a list of possible error codes.
Error code | Description |
---|---|
WSANOTINITIALISED |
A successful WSAStartupcall must occur before using this function. |
WSAENETDOWN |
The network subsystem has failed. |
WSAENOTSOCK |
The descriptor is not a socket. |
WSA_INVALID_HANDLE |
The hEventparameter of the WSAOVERLAPPEDstructure does not contain a valid event object handle. |
WSA_INVALID_PARAMETER |
One of the parameters is unacceptable. |
WSA_IO_INCOMPLETE |
The fWaitparameter is FALSE and the I/O operation has not yet completed. |
WSAEFAULT |
One or more of the lpOverlapped, lpcbTransfer, or lpdwFlagsarguments are not a valid part of the user address space. |
Remarks
This function reports the results of the last overlapped operation for the specified socket. This function is passed the socket descriptor and the WSAOVERLAPPEDstructure that was specified when the overlapped function was called. A pending operation is indicated when the function that started the operation returns FALSE and WSAGetLastErrorreturns WSA_IO_PENDING. When an I/O operation such as the WSARecvfunction is pending, the function that started the operation resets the hEventmember of the WSAOVERLAPPEDstructure to the nonsignaled state. Then, when the pending operation has completed, the system sets the event object to the signaled state.
If the fWaitparameter is TRUE, WSAGetOverlappedResultdetermines whether the pending operation has been completed by waiting for the event object to be in the signaled state. A client may set the fWaitparameter to TRUE, but only if it selected event-based completion notification when the I/O operation was requested. If another form of notification was selected, the usage of the hEventparameter of the WSAOVERLAPPEDstructure is different, and setting fWaitto TRUE causes unpredictable results.
With the exception of SIO_ROUTING_INTERFACE_CHANGE and SIO_ADDRESS_LIST_CHANGE, all network drivers running in the kernel and calling into Winsock APIs cannot use overlapped I/O. For more information, see WSARecv, WSARecvFrom, WSASend, WSASendTo, and WSAIoctl.
Requirements
Header | winsock2.h |
Library | Ws2.lib |
Windows Embedded CE | Windows CE .NET 4.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |