Network Programming with IOCP and Thread Pool – Intro

These days, I’m playing with network programming with IOCP and Thread Pool just for pure fun. 🙂 After several days of reading MSDN, articles and writing experimental codes, I’ve realized that there are pretty big changes I need to catch up.

If you still use IOCP with GetQueuedCompletionStatus() and your custom threads (like me before), you might want to follow this series of postings I will update. I will provide sample code to clarify the right way to use them.

Also, I will benchmark techniques to each other so that hopefully I can give you some guidelines about When we need to use Which technique, or, at least, help you to avoid making the same mistakes I would make while I write this series.

First of all, let’s see how many ways we can choose for using IOCP.

If we use custom threads to get I/O completion notification,

1. CreateIoCompletionPort() and GetQueuedCompletionStatus()
– Windows 2000 (Pro, Server) or later.

2. CreateIoCompletionPort() and GetQueuedCompletionStatusEx()
– Windows Vista and Server 2008 or later.

If we use Windows Thread Pool to get I/O completion notification,

3. BindIoCompletionCallback()
– Windows 2000 (Pro, Server) or later.

4. CreateThreadpoolIo(), StartThreadpoolIo() and etc
– Windows Vista and Server 2008 or later.

There also some APIs related to Thread Pool like QueueUserWorkItem(). Unfortunately, but in a good way, Thread Pool system has been completely re-written for Windows Vista and we need to use those new and richer APIs to maximize our server performance.

If it’s not confusing enough, I can tell you that there are also special socket functions which are Microsoft-specific extensions to the Windows Sockets specification. For example, ConnectEx(), AcceptEx() and etc. These functions are to fully utilize IOCP power for all IO operations including receive (read) and send (write).

Yes, it’s gonna be a long journey but it must be fun! So excited! LOL

Advertisements

About 리안 / Young

글쓰는 게임 프로그래머. 남편 그리고 아빠. Game Programmer Writing. A husband and a father.
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Network Programming with IOCP and Thread Pool – Intro

  1. iluzdaf says:

    Good luck on the journey! What are you planning to do with this tho?

  2. Young says:

    To build High Perforamcne and Scalable 64 bits Server based on IOCP witn Thread Pool for Windows Server 2008 R2? 🙂

  3. Pingback: IOCP with the original (or old) thread pool API. | The Game Programmer Writing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s