Socket Server code updates

The latest release of the free version of my asynchronous, windows, IOCP based, socket server framework can now be obtained from here at

For some time I’ve been promising to update the socket server articles to use the latest version of my code. Today I finally updated the code for the first article. I’m going to update the article itself soon, but in the meantime I’m posting the new code here.

[NOTE: This code leaks when adjusted to build with Visual Studio 2005. This seems to be due to a bug in VS2005’s STL. See here for a workaround. I expect to post a fix for this once I’ve found time to convert the code to build with the new compiler and then tracked down the leak. If anyone has already done this then a comment telling me what’s wrong would be appreciated.]

What’s new?

  1. You can now compile the code with VC6 without a Platform SDK installed. To do this, edit NoPlatformSDK.h and uncomment the #define.

  2. The sockets now share critical sections. The previous code suggested either allocating a critical section per socket, or sharing one section between all sockets, at the time I mentioned that this was less than ideal and that you’d probably want to do it differently in a production system. Now I’m including a shared critical section system that uses a hash to spread the contention across a pool of critical sections.

  3. Servers can now share the IO thread pool. You can now create multiple servers and have them share a single pool of IO threads. This makes creating servers that listen on multiple ports much less resource intensive.

  4. The server can now initiate outgoing connections as well as accept incomming connections.

  5. All examples can now build with VS.Net 2003 as well as VS.Net 2002 and VC 6. All examples come with project files for all three build systems.

  6. You can now have multiple user data “slots” per socket. This makes it easier to layer services on top of the server and still allow the client to add their own user data to each socket if they want.

  7. Each example ships with a test harness and config file to test the server as part of the build process, if required. Notice the difference in performance between the debug and release versions…

Code is here.