Hello guys,
I have been looking around for a while on how to resize a socket set in SDL_Net but I am not sure how to do it.
What I am looking for right now is a way to retreave the sockets that are members of the set so I can put them into another set which is resized and then delete the old one.
I have doubts that there is a way but if anyone could help me please reply.
3 replies to this topic
Ad:
#2 Members - Reputation: 579
Posted 31 October 2012 - 02:03 AM
The SDLNet_SocketSet is not a container meant to keep track of your sockets for you to retreive but more for SDLNet to use internally with select. If you store your sockets in one of the standard containers like a list, map or vector then you can easily grow a socket set by doing what you described as freeing a socket set does not free the contained sockets.
Evillive2
#3 Members - Reputation: 137
Posted 31 October 2012 - 06:53 AM
yes I have actually implemented my own container for the clients. but I still need to use socket sets if I want my server to be non-blocking. Maybe the clients don't need to be in a socketset for the whole lifetime of the application.
The Game Company [Game Makers Group] www.gamemakergroup.webs.com join us now
#4 Moderators - Reputation: 3292
Posted 31 October 2012 - 02:36 PM
Typically, you will create a socket set and add sockets to it each time you want to call select (assuming SDL socket sets are a thin wrapper around fd_set.) You typically also copy the socket set before calling select() so you can get different status for read, write, and exception status.
On UNIX, FD_SET() is a bit operation, and is very fast. On Windows, it's a fixed array size lookup, so it gets slower the more sockets you have, and tops out sooner (at 64 sockets unless you change FD_SETSIZE.)
On UNIX, FD_SET() is a bit operation, and is very fast. On Windows, it's a fixed array size lookup, so it gets slower the more sockets you have, and tops out sooner (at 64 sockets unless you change FD_SETSIZE.)
enum Bool { True, False, FileNotFound };






