What is the highest port number one can use?
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.
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
As I understand it, you should only use up to 49151, as from 49152 up to 65535 are reserved for Ephemeral ports
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.