SDLNet_UDP_Open

Hi,
SDL_UDP_Open doesn’t bind locally when passed port no. 0.Since
connectionless clients also need to bind locally wouldn’t it be better
to allow port no. 0 and call the UNIX bind with port 0 which will give
it a free port no.
The test chat client seems to groping for free ports with a for loop
and it doesn’t seem to be the best way.

SDL_UDP_Open doesn’t bind locally when passed port no. 0.Since
connectionless clients also need to bind locally wouldn’t it be better
to allow port no. 0 and call the UNIX bind with port 0 which will give
it a free port no.

Explicitly binding a local address isn’t always necessary. It depends
on what you are doing

The test chat client seems to groping for free ports with a for loop
and it doesn’t seem to be the best way.

I haven’t looked at the source, but that definitely sounds like a bad
idea to me. Letting the kernel choose the port (by binding with port=0)
is how it’s usually done

I haven’t looked at the source, but that definitely sounds like a bad
idea to me. Letting the kernel choose the port (by binding with port=0)
is how it’s usually done

Well,it’s being done that way because UDP_GetPeerAddress(sock,-1) is
being used to get the localhost’s IP Address and Port no. of the UDP
socket.
There’s no way as of now in SDL_net to get the port no. of a UDP socket
which does bind with port=0 Coz the code for UDP_Open looks like

if (port){
/* bind locally /
addr.port = port;
bind(…);
}
/
else do nothing */

The port is maybe assigned by the system during the first Send which is
not tracked by SDL_net.

So in short,all I’m asking is to remove this if condition and bind
locally whether or not the port==0.Then GetPeerAdddress(sock,-1) would
also work with socks that used bind with port=0.
EEKs,I must learn to say things in fewer lines.