kentoh - Fotolia

What is the difference between a socket and a port?

Sockets, ports and port numbers have functional overlap, but the terms are distinct. A socket is part of a port, while a port number is part of a socket. We explain.

At its most fundamental, a port is a physical endpoint on a piece of hardware -- such as a personal computer -- that acts as an interface, enabling connectivity with another external device -- such as a flash drive -- via a socket and a plug. A socket is the point of ingress and egress within a port, where a plug can be inserted to create a communication bridge between two devices.

What is a port?

Similarly, in computer networking, a port is a logical connection that two endpoints -- such as a client and server -- use to communicate. As a software construct, ports operate at the transport layer of the OSI protocol stack, with port numbers specifying the type of process or application running, such as email, web, voice and video. TCP or User Datagram Protocol packet headers include both source and destination port numbers.

What is a socket?

A socket represents one of the logical endpoints in a two-way networking connection. It works at the application layer, combining the IP address and port number to communicate the following information:

  • the identity of the client device on one side of a connection or the identity of the destination server on the other end; and
  • the application, such as a web browser, making the request on the client side of the connection or the application fulfilling the request on the server side.

Each socket has a unique socket descriptor that applications use to identify and access a specific socket. Essentially, a socket acts as a mailing address, indicating where and how to send traffic back and forth across a network, while a port number represents one identifying element within that specific address.

What is a port number?

If an IP address is like a zip code -- indicating a virtual neighborhood, or computing device, within a network -- then a port number is like the house number and street name, specifying which unit is involved in the communication. Web and HTTP clients, for example, use port 80 to send and identify data from webpages, while port 443 is reserved specifically for HTTPS traffic. A VPN client, on the other hand, connects to a VPN server over port 1723.

Dig Deeper on Network infrastructure

Unified Communications
Mobile Computing
Data Center