bind() test fails

James Hawkins truiken at gmail.com
Tue Jul 20 10:51:19 CDT 2004


Hi,

I ran the winsock tests and the only failure i received was from bind:

sock.c:660: Test failed: bind() failed error: 10048

I checked msdn and error 10048 is WSAEADDRINUSE.
The code for the test of this part is:

rc = bind(s2, (struct sockaddr*)&saddr, sizeof(saddr));
ok(rc==SOCKET_ERROR, "bind() succeeded\n");

reuse = 1;
rc = setsockopt(s2, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse, sizeof(reuse));
ok(rc==0, "setsockopt() failed error: %d\n", WSAGetLastError());

todo_wine {
rc = bind(s2, (struct sockaddr*)&saddr, sizeof(saddr));
ok(rc==0, "bind() failed error: %d\n", WSAGetLastError());
}

For this part of the test, we bind an address, saddr, with a socket,
s2, and then set the SO_REUSEADDR option to 1 so that we should be
able to bind again, but we're getting the error WSAEADDRINUSE which
means that the fact that we are allowing multiple binds with the
SO_REUSEADDR option is being ignored somewhere.

I looked at the function declarations for the win32 and linux setsockopt.

win32:
WS_setsockopt(SOCKET s, int level, int optname, const char *optval, int optlen)

linux:
setsockopt (int __fd, int __level, int __optname, __const void
*__optval, socklen_t __optlen)

At one point in WS_setsockopt we make a call to the linux setsockopt
and im wondering if the problem is when we call this version.  Is it
not a problem that WS_setsockopt's optval parameter is of type const
char * and setsockopt's optval parameter is __const void *?

I've searched for a while about this problem and I can't seem to spot
the fix.  If i'm totally off the mark on this one, let me know as
well.  Thanks for the help.

For further reference see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/setsockopt_2.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/using_so_exclusiveaddruse.asp
-- 
James Hawkins



More information about the wine-devel mailing list