• Advertisement
Sign in to follow this  

SDL_Net Resizing the socket set

This topic is 1908 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement