After studying the code, I think several functions must be clear about the principle. To understand the code and understand the process.
Asynchronous mode: similar to form. Show ();
Blocking Mode: similar to form. showmodal ();
Wsaaccept;
When the client has a connection request, the wsaaccept function will create a new socket csocket.
For other parameters, see msdn and Google.
One thing to note is that this function is not asynchronous and is in blocking mode.
Wsarecv;
Collect socket data
This function is in asynchronous mode and will be returned immediately after execution.
After the data is received, getqueuedcompletionstatus will return
Getqueuedcompletionstatus:
Obtain the request from the specified iocp Request queue.
When the queue is empty, calls to this function will be blocked.
When the queue is not empty, the blocked thread will be requested later in the first-in-first-out (LIFO) Order.
Postqueuedcompletionstatus:
Csdn
Posts an I/O completion packet to an I/O completion port.
Post an I/O completed packet to the IO completed port.
// There is also a blogs as described above
>>> The postqueuedcompletionstatus function sends a special completion packet to each worker thread. This function indicates that each thread "ends immediately and exits ".
From: http://hi.baidu.com/drunkdream/item/b4b4b649dd6c9b0fc01613ac
>>>> I want to perform such a test and run postqueuedcompletionstatus after the accept connection,
Postqueuedcompletionstatus (lvioport, 0, 0, nil );
Enable getqueuedcompletionstatus for only one thread and return values.
>>>>>>
My understanding is:
If you want to send a data packet to the queue on the I/O port, a getqueuedcompletionstatus will be triggered. getqueuedcompletionstatus in a thread that does not have a returned value.
In the next section, we will study the actual use of these functions.