network socket
One end of a two-way network connection between programs, identified by an IP address and a port number.
In more detail
A program opens a socket to connect to a server, and the operating system uses the address and port to deliver data to the right program. Many requests to the same server can reuse one open socket.
Examples
In the browser: the TCP handshake sets up the socket and TLS then encrypts what flows through it.A program asks the kernel for a socket, binds it to a local address and port, and then either listens for connections or connects out. Each open socket is also a file descriptor of its process. ss lists sockets with their state and owning process.In Node.js a TCP socket is a Duplex stream.Python's ssl module wraps a plain socket to add TLS on top; the course runs both ends of a handshake over loopback sockets in one process.Related terms
- TCP — The internet protocol that delivers data between programs reliably and in order, used by the web and most databases.
- port — A number from 1 to 65535 that picks out one service on a machine, such as 22 for SSH or 80 for plain web traffic.
- IP address — The numeric address, such as 192.168.1.10, that identifies a machine or container on a network.
- TCP three-way handshake — The three-message exchange, SYN, SYN-ACK and ACK, that a client and server use to open a TCP connection before sending data.
- listening socket — A socket that has claimed a local address and port and is waiting to accept incoming connections.
- bind address — The network address a server listens on, which decides who can connect to it.
- socket state — The stage a TCP socket has reached in its lifecycle, such as LISTEN, SYN-SENT, ESTABLISHED or TIME-WAIT.
- file descriptor — A small number the operating system gives a process for each open file, socket or pipe, used in every later read or write.
- Duplex stream — A Node.js stream that is both readable and writable, with the two sides independent, such as a TCP socket.
- TLS — The encryption that protects data travelling over a network, the S in HTTPS.
- connection gateway — A server that holds long-lived client connections and relays messages to and from them, storing nothing durable.
Taught in
- How Browsers Work: Navigation, DNS, TCP, TLS And Request Timing — Frontend Architecture & Web Platform
- The Fetch API: Streaming Responses, HTTP Caching And Keepalive — Frontend Architecture & Web Platform
- Ports, Sockets And What Listening Means — Linux Fundamentals & Systems Administration
- The Handshake, And The States A Socket Passes Through — Linux Fundamentals & Systems Administration
- libuv Architecture: Event Demultiplexer & Thread Pool — Node.js Internals & Backend Services
- Event Loop Lifecycle: The Six Phases & libuv uv_run — Node.js Internals & Backend Services
- Poll & Check Phases: I/O Callbacks & setImmediate — Node.js Internals & Backend Services
- Close Phase & Signal Dispatch: Sockets & Teardown — Node.js Internals & Backend Services
- Native HTTP Server: Request & Response Lifecycles — Node.js Internals & Backend Services
- Native WebSockets: Bidirectional Real-Time Streams — Node.js Internals & Backend Services
- TLS And The Handshake — Application Security & Threat Modeling for Engineers
- Broken Object Level Authorization — Application Security & Threat Modeling for Engineers
- Worked Design Two: A Global Chat System — Scalable System Design & Distributed Architecture
- Worked Design Two: Scaling Chat Fan Out — Scalable System Design & Distributed Architecture