Expressvpn Glossary
Network socket
What is a network socket?
A network socket is a communication endpoint that allows programs to send and receive data over a network. It connects an application to the network, enabling devices to exchange information using protocols like Transmission Control Protocol (TCP) or User Datagram Protocol (UDP).
At a system level, a socket serves as a standardized interface for applications to exchange data without handling low-level networking tasks.
How does a network socket work?
Each socket is identified by a combination of an IP address, port number, and transport protocol, which together help direct traffic to the correct application on the correct device.
In a typical TCP client-server exchange, a server creates a socket, binds it to a local address and port, and puts it in listening mode. When a client requests a connection, the server accepts the connection and uses the connected socket to send and receive data.
With TCP, both sides exchange data over an established connection. With UDP, the socket sends and receives individual datagrams without a persistent connection. When communication is complete, the application can close the socket, although servers often keep listening sockets open to continue accepting new connections.
Types of network sockets
Different types of network sockets handle different transmission needs, depending on whether reliability, speed, or low-level control matters most.
- Stream sockets: Typically use TCP to provide reliable, connection-based communication. Data arrives in order, and the protocol detects errors and retransmits missing or corrupted data.
- Datagram sockets: Typically use UDP to send connectionless messages. This is faster and has lower overhead than TCP, but it doesn’t guarantee delivery, order, or retransmission.
- Raw sockets: Provide direct access to lower-level network protocols, allowing programs to read or manipulate packet headers. These typically serve network analysis, diagnostics, or specialized applications.
Why are network sockets important?
Network sockets enable essential communication between applications, whether they run on the same machine or across a network.
They also support many everyday online interactions by giving software a standard way to exchange data. When paired with Transport Layer Security (TLS), sockets can carry encrypted traffic, helping protect data from eavesdropping or tampering.
Because they sit at the point where applications send and receive network data, sockets are also relevant to how security tools observe and manage traffic.
Where are network sockets used?
Network sockets support many everyday applications and services that rely on data exchange between systems.
- Web browsers and web servers: Load websites by sending requests from a browser to a server and receiving responses over protocols like HTTP or HTTPS.
- Virtual private network (VPN) apps: Use socket-based networking to communicate with remote VPN servers and carry encrypted tunnel traffic.
- Email and chat services: Send and receive messages between users in real time or near-real time through persistent or session-based connections.
- Domain Name System (DNS) lookups and API traffic: Resolve domain names and exchange data between applications and services in the background.
- Network monitoring tools: Capture and analyze network traffic to track activity, diagnose issues, or support security investigations.
Risks and privacy concerns
While network sockets are essential for communication, they can introduce security and privacy risks without proper management.
- Expanded attack surface: Attackers can discover and target services that expose sockets to the network.
- Service exposure: An incorrect socket or service configuration can unintentionally expose internal systems to external traffic.
- Traffic interception: Third parties may capture unencrypted traffic or, in some cases, modify it through man-in-the-middle (MITM) attacks.
- Packet manipulation: Attackers with raw socket access or similar low-level network access may forge or alter packet headers.
- Unauthorized access: Weak authentication or inadequate access controls can allow unauthorized connections.
Further reading
- What are network protocols? A complete guide
- TCP vs. UDP: Understanding the key differences and best use cases
- What is an open port? A guide to network vulnerabilities
- What are VPN ports?
- Port 443: What it is, how it works, and how to use it safely