Port numbers are the form of source and destination addressing found at OSI layer four, the transport layer.
TCP and UDP each feature 16-bit fields for both source and destination port number. This allows for a port number ranging from 0 to 65,535. Port numbers are intended to map to specific applications or application instances. The combination of port number and IP address creates a network socket, the logical pipeline through which network-aware applications can send and receive data over a network.
Port numbers 0 through 1023 are called the well-known ports. These ports are used for common applications. Some examples include Telnet (TCP port 23), HTTP (TCP port 80), and DNS (TCP and UPD ports 53).
Port numbers 1024 through 45,191 are called registered ports. These port numbers can be registered for commerical use through IANA.
Port numbers 45,192 through 65,535 are called private, dynamic, or ephemeral. These ports are intended for transitory use by applications for a particular session only.
As a practical matter, there is no enforcement of the defined usage of port numbers within a particular category, and applications will often use well-known ports or ports registered to other organizations. Traditional firewalls rely heavily on port number filtering, but given the current trend toward tunneling many different types of application traffic through HTTP's port 80, this defensive technique is losing some of its impact.