TCP uses the notion of port numbers to identify sending and receiving
applications. Each side of a TCP connection has an associated 16-bit port
number assigned to the sending or receiving application.
Ports are categorized into three basic categories: well known, registered
and dynamic. Well known ports are assigned by the Internet Assigned Numbers
Authority (IANA) and are typically used by system-level processes. Well
known applications running as servers use these ports. Some examples include:
SMTP (25) and
HTTP (80). Registered ports are typically
used by services that have been registered by a third party. Dynamic ports
can be used by end user applications.
Internally, in the operating system a socket forms the endpoint of the
communication. It is defined as the combination of an IP address, a protocol,
and the port number.