How those giant online gamming servers work?

Started by
15 comments, last by GameDev.net 19 years, 4 months ago
Correct me if I'm wrong but the limit isn't 65535, its just the amount of RAM available to hold connection information. A TCP connection is defined by Source IP+Port AND Destination IP+Port and not just by the port # on the server machine.
Advertisement
Hello All,

On Unix systems, at lest The ones I use (DEC Sun), there is a limit to the number of open file descriptor a process can have open. sockets are special file desc.
This can be change to max which is 65535.
But you get only 65535-3=65532 useful file desc that you can use.
Why -3 because there is cout, cin and cerr which you get when process runs.

Now M$ windows doesn't use file desc they use handles, basicly the same thing. But there is even a smaller max limit on most of Windwos OS, expect the Server versions which allow more.

I think on unix side this limt of 65535 file desc is so the kernel doen't need to be over large holding tables for these file desc for each process when most of the time most process won't have but a few to tens of file desc open at a time.

Lord Bart :)
Open file descriptors are a separate point. The defaults for number allowed are in the low hundreds to low thousands, unless (as you point out) you override them.

But if that were all, then you'd just launch additional processes to get another 2^16 ports each time.

I'm gonna try looking this up (dunno waht search terms to use htough without getting lots of crap) because I have a feeling that linux now has a higher number (2^32 perhaps?) addressable.

That's the real question: how many can the OS address? Once you know that, it's simply an implementation issue of your program how many you can usefully use.
I believe that IPv4 only allows a 16bit number for allocating a name to a bound socket, no?

In which case, linux can only go over 2^16 ports if running something else (maybe IPv6 has a more sensible upper limit? 2^16 isn't much headroom for the next 30 years...)
Or you just use UDP, a single port, and "any number" of clients using whatever addressing you want internally to your application protocol.
enum Bool { True, False, FileNotFound };
Hello All,

I look around, and found a few site about limits in open file desc.
http://httpd.apache.org/docs/misc/descriptors.html
http://bbcr.uwaterloo.ca/~brecht/servers/openfiles.html

I would think that if there is a limit to number of open file desc per process.
You could have a controling process parent that start a child process then it is told by the child that it at max open files.
The child would stop accept new connections, the parent would start a new child process that can accept new conntions. While the first frees up connections and when 2nd child full up and when full tell the parent which could tell first to child start accepting agian.

It would be a little complex but doable.

Lord Bart :)
That's what I already said.

This topic is closed to new replies.

Advertisement