views:

3376

answers:

6

What is the highest port number one can use?

+10  A: 

The port number is an unsigned 16-bit integer, so 65535.

Greg Hewgill
+9  A: 

The largest port number is an unsigned short 2^16-1: 65535

A registered port is one assigned by the Internet Corporation for Assigned Names and Numbers (ICANN) to a certain use. Each registered port is in the range 1024–49151.

Since 21 March 2001 the registry agency is ICANN; before that time it was IANA.

Ports with numbers lower than those of the registered ports are called well known ports; port with numbers greater than those of the registered ports are called dynamic and/or private ports.

Source

Brian R. Bondy
+3  A: 

Depending on which range your talking about but the dynamic range goes up to 65535 or 2^16 (16 bits).

http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

Jim Burger
65535 = 2^16 - 1
Chris Charabaruk
+2  A: 

It should be 65535.

Chris
+6  A: 

As I understand it, you should only use up to 49151, as from 49152 up to 65535 are reserved for Ephemeral ports

Smashery
+5  A: 

Just a followup to smashery's answer. The ephemeral port range (on Linux at least, and I suspect other Unices as well) is not a fixed. This can be controlled by writing to /proc/sys/net/ipv4/ip_local_port_range

The only restriction (as far as IANA is concerned) is that ports below 1024 are designated to be well-known ports. Ports above that are free for use. Often you'll find that ports below 1024 are restricted to superuser access, I believe for this very reason.

Andrew Edgecombe