Delphi-iocp learning notes ==== introduction and understanding of basic iocp Functions

Source: Internet
Author: User

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 ();



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.



Collect socket data

This function is in asynchronous mode and will be returned immediately after execution.

After the data is received, getqueuedcompletionstatus will return




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.





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 ".


>>>> 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.