[SDL] SDL_Net Server Stuff
tilgovi at optonline.net
Sat Feb 16 12:04:00 PST 2002
I'm writing a server for an RPG using SDL_Net and I'm running into some
I'm wondering how I should handle the UDP sockets for incoming messages
The easiest thing to do as I see it would be to create a socket for each
player on different
ports. So, I guess the question is: What is the best way to find an
unused port? I could
call SDLNet_UDP_Open(0), but the client has to know what port it ended
SDLNet_UDP_GetPeerAddress doesn't work for ports opened that way though.
My next idea was to create one socket and accept all packets on that
port, and tag each
packet with an ID corresponding to a player ID. I could then go through
a binary tree
of the players placed by ID and find the player who needs the packet.
Then that Player
object would handle the body of the packet.
Any suggestions, answers, comments?
What's the best way to do this?
More information about the SDL