[SDL] Re: SDL_net Socket listeners not unique?
Ryan C. Gordon
icculus at clutteredmind.org
Tue Sep 27 05:09:16 PDT 2005
> I just accidentally did the same thing as you on Windows 2000, and yes indeed
> one can open multiple server sockets on the same port! Must be a bug in
> SDL_net, though I haven't been able to find it... mayby we should bug the
WinSock and BSD sockets let you do this if you specify SO_REUSEADDR to
setsockopt(), which SDL_net happens to do if you are binding to either
INADDR_NONE (255.255.255.255) or INADDR_ANY (0.0.0.0).
The previous example passed a NULL to SDLNet_ResolveHost(), which
My understanding is that this is there so that you don't have to wait
for the previous socket to die out if you are starting and stopping the
program that binds the socket a lot (such as, say, when debugging a
server) and obviously only affects listen sockets.
I think the last time I ran into this (a LONG time ago), Windows would
just toss connections to the different sockets seemingly randomly (and
for UDP sockets, toss individual PACKETS to the different connections
randomly!)...I can't remember what Linux did. Not sure if that's
actually true and/or different due to my flakey memory and Windows
The quickest fix is "just don't bind the same port twice".
More information about the SDL