65535 outbound connections

Bill Moran wmoran at potentialtech.com
Fri Mar 9 12:49:30 UTC 2007


In response to Atis <atisss at gmail.com>:

> On 3/9/07, Niklaus <niklaus at gmail.com> wrote:
> > Hi
> >
> > I could be wrong in the below description or might have misunderstood
> > many of the concepts , please correct appropriately.
> >
> >  65535 ports can allowed . So on a  machine namely C you can have max
> > 65535 outbound connections
> 
> There can be simultaneous connections to one port. For example
> apache's httpd - it listens port 80, does that mean, it can serve only
> one connection? nope. Once connection is established, it's forwarded
> to another thread, that have connection id, and processes it.
> 
> Don't know about outgoing connections, but i think, they also can be
> simultaneous.

No.  Outgoing connections must always grab a unique port.

The upshot is that the "socket pair", which is the IP:port of one end of
the connection, plus the IP:port of the other end, must always be unique.

Since a listening socket (server) will frequently have many connections to
the same port, client side apps _must_ pick a unique port each time, to
protect from network failure.  This is enforce by the operating system.

So, the total number of (theoretical) connections is limited by the product
of IP space * port range.  But the total number of available outgoing
connections is limited by the port range, and that's where that 65536 
comes from.

-- 
Bill Moran
http://www.potentialtech.com


More information about the freebsd-questions mailing list