Hi,

(this is about Windows socket programming but the question is partially
related to Linux and this is the only forum I know were heavy weight network
programmers lurk).

At my workplace we have to do tons of DNS lookups at one stage of the data
processing.

I suggested to use the following method instead of gethosybyname(3) or
synchronous thread-per-query:

1. create a single UDP socket.
2. have one thread shooting as many DNS queries through this socket as it
can.
3. have multiple "reader" threads simply running recv(2) on the same socket
and processing the replies.

When our dev team tried to implement this on Windows they discovered
something strange:

1. the first batch of send(2)'s runs great.
2. the replies get recv(2)'ed by the reading threads.
3. the reading threads block on the recv(2) after the last reply has arrived
(which is just what I expected)
4. the first send(2) of the next batch get blocked(!).

It looks like the recv(2) blocks the send(2) on the same socket.

We are trying to find ways to avoid this block (any suggestions are welcome,
so far dup'ing the sockets failed and having two separate sockets bound to
the same port with REUSEADDR works intermittently) but I was wondering
whether my suggestion makes sense in general and we are just hitting yet
another Windows stupidity (and it would work on Linux, another argument in
favour of Linux) or do I miss something fundamental.

Thanks,

--Amos

Reply via email to