bogus patch to bind() dlls/winsock/socket.c (request removal)

Jeremy Shaw at
Thu Jan 8 14:14:29 CST 2004

As a result of this patch (which is currently applied in cvs head):

WS_bind() currently does this before every call to bind():

 WS_setsockopt( s, WS_SOL_SOCKET, WS_SO_REUSEADDR, (char*)&on, sizeof(on) );

Basically, it sets SO_REUSEADDR for every call to WS_bind().

I can't imagine this is the correct thing to do. According to MSDN,
bind() should fail unless the program has explicitly set SO_REUSEADDR.

See Error code WSAEADDRINUSE at:

I found that this patch causes major problems with the xten sipphone
client. The xten client does not explicitly set SO_REUSEADDR and
depends on bind() failing if it tries to bind to the same local
address/port twice.

When the sipphone client needs a socket, it starts at port 8000, and
calls bind() on successive ports until bind() returns success. So
normally, if the program is already using port 8000, then bind() will
fail and will try port 8001. However, with the above patch in place,
bind() always works. So then the sipphone client will be using port
8000 twice, which the program is not designed to handle.

If I remove the call to WS_setsockopt(), the xten sipphone client works

I am proposing that the portion of the patch applied to WS_bind() be
removed unless someone has a convincing arguement that the patch is
actually valid.

Jeremy Shaw.

More information about the wine-devel mailing list