When using CreateIoCompletionPort()
to associate a SOCKET
with a completion port, can I pass a direct value (i.e. not a pointer) to the CompletionKey
parameter, or should I only pass a pointer?
What I want to do is to pass the SOCKET
value.
The CompletionKey
parameter to CreateIoCompletionPort is of type ULONG_PTR
. It is large enough to hold a ULONG
or a pointer type, whichever is larger. You can pass any value, that fits in a ULONG_PTR
. A SOCKET
meets this requirement.
See winsock2.h:
typedef UINT_PTR SOCKET;