Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Socket.UBound
#1
I know I asked this before, but I don't remember the answer. Why don't we use

Code:
for i=1 to socket.ubound

instead of

Code:
for i=1 to MAX_PLAYERS
?
Reply
#2
Dave Wrote:why don't we?
Was that some sarcastic thing or something xD ?
Reply
#3
William Wrote:
Dave Wrote:why don't we?
Was that some sarcastic thing or something xD ?

Have you tested it at all to see if it works just as good? Maybe test it out on your next beta for K2H and give us some feedback. Or if you want, I can test it out on M:R. That seems to have players on quite a bit.

It would prolly just be a matter of seeing how it reacts when you login, someone else logs in, you logout, and login again.
Reply
#4
I don't see why it wouldn't work since the uBound (upperbound I think it is). Gets the new index before highindex does if thats now added. Well it's pretty simple to test, so I might do it. Just wanted to know why people havn't thought of it before. Etc..
Reply
#5
Where exactly is that done?
Reply
#6
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).
Reply
#7
Eh, something is wrong with ubound. I made a server so people using rpg toolkit could play online. And ubound works there, but it doesn't seem to work in ms. I need to try a little more later.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)