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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Jun 30 10:03:51 EDT 2012

At Sat, 30 Jun 2012 00:33:36 +0200, Rüdiger Asche wrote:
> All of this runs fine for a while, until ALL of the stress clients
> begin to raise WSAEADDRESSINUSE exceptions. [...] 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?

That's essentially correct. More precisely, Racket doesn't call bind(),
so connect() is responsible for picking a free port number.

> Or does the Racket TCP/IP translation layer do 
> its own magic with local port selection

No --- unless you provide a fourth argument to `tcp-connect', of
course, in which case bind() is used before connect(), but you
mentioned that you provide only two arguments to `tcp-connect'.

> any ideas?

With 12 clients running full blast on the same machine(?), maybe you
really are running out of ports for connect() to pick from, as Neil

It appears that Windows XP uses the range 1025 to 5000 for ephemeral
ports, while later versions of Windows apparently use 49152 to 65535.
So, there are 3976 or 16383 port numbers for connect() to choose from,
depending on the version of Windows that you're using.

Posted on the users mailing list.