tokuhirom/test-tcp — pull request #4 by wchristian (2012-07-27 20:23:24+00:00)
Title: fix port checking on Win32 by performing it in another process

On Win32 fork is emulating by creating another thread in the same process.
This leads to a possible bug/race condition when a server tries to open a
port and listen on it, while in the same process a client tries to connect
to the same port. This manifests by the accept call of the server failing
with an error of "Bad file descriptor".

This is easily fixed by having another process perform the port checking,
since that will not interfere with the internals.

The necessary change is implemented in this commit and only necessary for
win32. It does however work everywhere else with no downside so special
casing is not necessary or useful.