[racket] strange issue with tcp-connect on Windows...

From: Rüdiger Asche (rac at ruediger-asche.de)
Date: Fri Jun 29 18:33:36 EDT 2012

Hi there,

today's bug from hell might not be a Racket related issue (to me it seems more of a Windows type of thing), but maybe somebody has already come across something similar, so here goes:

I have a Racket application serving as a stress test against a TCP server, that is, the Racket application calls tcp-connect() to the remote server, then does some data exchange, closes the ports and starts all over again. To make it more interesting, I have 12 instances of this application running concurrently, so there is quite a lot of connection establishment and -takedown going on.

So far, so good - only thing I need to mention is that I call tcp-connect only with the minimum necessary parameters (remote name and remote port).

All of this runs fine for a while, until ALL of the stress clients begin to raise WSAEADDRESSINUSE exceptions. Now I understand that WSAEADDRESSINUSE means that an application tries to bind a socket to a local port that is already used for another connection - but in the case of tcp-connect(), I assume that the call with no local port translates to a bind() with port 0 which instructs the TCP layer to select a free port? Or does the Racket TCP/IP translation layer do its own magic with local port selection which might be buggy?

I also understand that the OS will keep bound sockets around for a while (which can be easily verified by looking at the netstat() output), but the "normal" BSD compatible implementation of bind(...0...) will skip sockets in those states, so I don't quite understand where the WSAEADDRESSINUSE error comes from unless the port selection was made outside of the low level network software...

any ideas?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120630/c96fc924/attachment-0001.html>

Posted on the users mailing list.