Creates an I/O completion port with no associated file descriptor or associates an opened socket or file with an existing or newly created I/O completion port.
#include <iocp.h>
int CreateIoCompletionPort (FileDescriptor, CompletionPort, CompletionKey, ConcurrentThreads)
HANDLE FileDescriptor, CompletionPort;
DWORD CompletionKey, ConcurrentThreads;
The CreateIoCompletionPort subroutine creates an I/O completion port or associates an open file descriptor with an existing or newly created I/O completion port. When creating a new I/O completion port, the CompletionPort parameter is set to NULL, the FileDescriptor parameter is set to INVALID_HANDLE_VALUE (-1), and the CompletionKey parameter is ignored.
The CreateIoCompletionPort subroutine returns a descriptor (an integer) to the I/O completion port created or modified.
The CreateIoCompletionPort subroutine is part of the I/O Completion Port (IOCP) kernel extension.
Item | Description |
---|---|
FileDescriptor | Specifies a valid file descriptor obtained from a call to the socket or accept subroutines. |
CompletionPort | Specifies a valid I/O completion port descriptor. Specifying a CompletionPort parameter value of NULL causes the CreateIoCompletionPort subroutine to create a new I/O completion port. |
CompletionKey | Specifies an integer to serve as the identifier for completion packets generated from a particular file-completion port set. |
ConcurrentThreads | This parameter is not implemented and is present only for compatibility purposes. |
Upon successful completion, the CreateIoCompletionPort subroutine returns an integer (the I/O completion port descriptor).
Item | Description |
---|---|
EBADF | The I/O completion port descriptor is invalid. |
EINVAL | The file descriptor is invalid. |
EALREADY | The file descriptor is already associated. |
c = CreateIoCompletionPort (INVALID_HANDLE_VALUE, NULL, 0, 0);
c = CreateIoCompletionPort (34, NULL, 25, 0);
c = CreateIoCompletionPort (54, 12, 15, 0);