Jump to content

  • Log In with Google      Sign In   
  • Create Account

SDL_Net Resizing the socket set


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 retroworld   Members   -  Reputation: 164

Like
0Likes
Like

Posted 30 October 2012 - 03:04 PM

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.

Sponsor:

#2 evillive2   Members   -  Reputation: 696

Like
0Likes
Like

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 retroworld   Members   -  Reputation: 164

Like
0Likes
Like

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.

#4 hplus0603   Moderators   -  Reputation: 5711

Like
0Likes
Like

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.)


enum Bool { True, False, FileNotFound };




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS