tags:

views:

522

answers:

4

How many sockets can be created from a port?

+4  A: 

This is an operating system limit.

Basically each socket will require a file descriptor (in Linux/Unix terms; it's probably equivalent in Windows). The OS will have a per-process file descriptor limit (say 250-1000) and that'll be the upper limit.

cletus
+2  A: 

It's operating system dependent.

  • For Windows, look here for the MaxConnections entry.

  • For Linux, look here as the comment on question says.

FerranB
+1  A: 

That'll be governed by the number of client-side ports available to your process (that i, when you open a connection to a remote host/port combination, you will also require a port at your end).

The total of client side (or ephemeral) ports will be made available to all the processes on your machine. So it depends on what else is currently running.

The number of ports and the configuration is OS dependent. Just Google for 'max number of ports' plus your OS.

Brian Agnew
+1  A: 

You can change this on UNIX-like boxes with ulimit. On my mac I can get around 22000 sockets, which I believe is a limit built into the kernel.

The theoretical limit is around 2^16 = 65536, because each socket requires a port number and those numbers are 16-bits.

I also note that my system uses around 200 sockets normally, the rest being available to my apps.

65536 is just plain wrong as you can open listenings socket on specific interfaces only. That multiplies the 2^16 with the number of interfaces you have.
Bombe
It's not wrong, it is a per interface number. It may be multiplied by the number of interfaces. And you still have to direct traffic to those interfaces in a practical setup.