[zeromq-dev] Using IOCP for polling on Windows

Martin Sustrik sustrik at 250bpm.com
Thu Aug 19 09:24:40 CEST 2010

Hi all,

There have been some discussion of using IOCP instead of select on 
Windows platform. Here's a reply from MS about combining BSD sockets and 
IOCP -- kindly shared by Mike (mike at coastrd.com).



Firstly, in Windows, "sockets are sockets".  That is, we don't 
distinguish between a BSD, a Winsock, or a Windows socket - it's all 
just a socket.

However, as soon as you decide to use overlapped structures (which you 
need to do to use completion ports), you have to use the WSASend (etc) 
function instead of send(), and you have to use the WSABUF structure 
instead of just sending data.  These are far enough from being BSD 
sockets that you probably cannot re-use the existing BSD code.

You might be able to make a sort of "translation layer" with macros and 
classes that hide these details.  But it would involve changing the 
socket layer code.

As always, the strongest recommendation I can make for making code run 
faster is: always benchmark first.  It's often a surprise to find out 
exactly what part of the code is actually responsible for the time.

I notice that you didn't answer the "motivation" question. This can be a 
very important question - for example, if the motivation is that you 
need to fill up a 10 gig pipe (some of my customers absolutely need to 
do this), then what you need to do will change (e.g., you'll need to 
look into receive-side scaling)

More information about the zeromq-dev mailing list