Dequeues a completion packet from a specified I/O completion port.
#include <iocp.h>
boolean_t GetQueuedCompletionStatus (CompletionPort, TransferCount, CompletionKey, Overlapped, Timeout)
HANDLE CompletionPort;
LPDWORD TransferCount, CompletionKey;
LPOVERLAPPED Overlapped; DWORD Timeout;
The GetQueuedCompletionStatus subroutine attempts to dequeue a completion packet from the CompletionPort parameter. If there is no completion packet to be dequeued, this subroutine waits a predetermined amount of time as indicated by the Timeout parameter for a completion packet to arrive.
The GetQueuedCompletionStatus subroutine returns a boolean indicating whether or not a completion packet has been dequeued.
The GetQueuedCompletionStatus subroutine is part of the I/O Completion Port (IOCP) kernel extension.
Item | Description |
---|---|
CompletionPort | Specifies the completion port that this subroutine will attempt to access. |
TransferCount | Specifies the number of bytes transferred. This parameter is set by the subroutine from the value received in the completion packet. |
CompletionKey | Specifies the completion key associated with the file descriptor used in the transfer request. This parameter is set by the subroutine from the value received in the completion packet. |
Overlapped | Specifies the overlapped structure used in the transfer request. This parameter is set by the subroutine from the value received in the completion packet. For regular files, this parameter contains a pointer to the AIOCB for a completed AIO request. If an application uses the same completion port for both socket and AIO to regular files, it must use unique CompletionKey values to differentiate between sockets and regular files in order to properly interpret the Overlapped parameter. |
Timeout | Specifies the amount of time in milliseconds the subroutine is to wait for a completion packet. If this parameter is set to INFINITE, the subroutine will never timeout. |
Upon successful completion, the GetQueuedCompletionStatus subroutine returns a boolean indicating its success.
Item | Description |
---|---|
ETIMEDOUT | No completion packet arrived to be dequeued and the Timeout parameter has elapsed. |
EINVAL | The value of the CompletionPort or other parameter is not valid. |
EAGAIN | Resource temporarily unavailable. If a sleep is interrupted by a signal, EAGAIN may be returned. |
ENOTCONN | Socket is not connected. The ENOTCONN return can happen for two reasons. One is if a request is made, the fd is then closed, then the request is returned back to the process. The error will be ENOTCONN. The other is if the socket drops while the fd is still open, the requests after the socket drops (disconnects) will return ENOTCONN. |
EBADF | This error code might also be returned when the value of the CompletionPort parameter is not valid. |
int transfer_count, completion_key
LPOVERLAPPED overlapped;
c = GetQueuedCompletionStatus (34, &transfer_count, &completion_key, &overlapped, 1000);