I need to develop an application that uses IOCP in a UDP socket, but the material found both in the Microsoft documentation as other examples or are vague or focus in the form of implementation. I would like someone with experience in the use of IOCP confirm that the correct usage is:
- Call CreateIoCompletionPort function to create an IOCP.
- I associate my socket to my IOCP with the same function.
- Perform an IO operation (WSARecvFrom or WSASendTo in my case)
- Call GetQueuedCompletionStatus function that will block my process until my IO operation has completed (this can be done in a thread pool for example)
- Realize the reading of the buffer or the operation result.
I have not described the implementations of the socket because it is not the focus, but is this the correct way to work with IOCPs?
A second question is about the application design, in the case of sending information. I read something that said that the application that works with IOCPs would not use direct calls to the output operations (such as call directly WSASendTo function), but use the PostQueuedCompletionStatus function to generate an event in the thread to run this operation. According to what I've studied, I don't see any advantage in terms of performance.
Assuming that both forms are applied to a thread pool, there is advantage in using PostQueuedCompletionStatus to perform the output operation?