SDL_Net Resizing the socket set

Started by
2 comments, last by hplus0603 11 years, 5 months ago
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.
Advertisement
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
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.
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.)

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement