24-10-2007, 05:54 PM
So simply create the socket array with only a single element in the beginning.
Then when new sockets are needed, we can simply add a socket (with the MAX_PLAYERS simply setting a number that the server will not exceed).
Then when someone disconnects, check to see what the highest socket number is that is in use, and unload all sockets above that number.
Basically, you'd simply load sockets when you need them and unload the ones that you don't need (as long as they're not in the middle of the array... I made that mistake one time).
Or you could just leave them loaded and not unload them. It'd still reduce the number of sockets you have loaded within the first moments of the server being up (depending on how popular the game is, if you never have more than 5 people at a time, then the server will never have more than 5 sockets loaded at a time... minus the listening socket which doesn't really count).
Then when new sockets are needed, we can simply add a socket (with the MAX_PLAYERS simply setting a number that the server will not exceed).
Then when someone disconnects, check to see what the highest socket number is that is in use, and unload all sockets above that number.
Basically, you'd simply load sockets when you need them and unload the ones that you don't need (as long as they're not in the middle of the array... I made that mistake one time).
Or you could just leave them loaded and not unload them. It'd still reduce the number of sockets you have loaded within the first moments of the server being up (depending on how popular the game is, if you never have more than 5 people at a time, then the server will never have more than 5 sockets loaded at a time... minus the listening socket which doesn't really count).