Socket Addresses in TCP/IP

TCP/IP provides a set of 16-bit port numbers within each host. Because each host assigns port numbers independently, it is possible for sockets on different hosts to have the same port number.

To ensure that socket addresses are unique within a network, TCP/IP concatenates the internet address of the LAN interface with the port number to devise the internet socket address. Since a host's internet address is always unique within a network, the socket address for a particular socket on a particular host is unique. Additionally, since each connection is fully specified by the pair of sockets it joins, every connection between internet hosts is also uniquely identified.

The port numbers from 0 to 1023 are reserved for official internet services. Port numbers in the range of 1024-49151 are reserved for other registered services that are common on internet networks. These port numbers are listed in the ETC\SERVICES file. When a client process needs one of these well-known services at a particular host, the client process sends a service request to the socket address for the well-known port at the server.

The port numbers from 49152 to 65535 are generally used by client processes which need a port, but don't care which one they get. These port numbers are usually assigned by the TCP/IP stack when a connect() or sendto() is performed without having done a previous bind().


[Back: Socket Address Data Structures]
[Next: Connection Modes]