Socket
ELI5 — The Vibe Check
A socket is the combination of an IP address plus a port number — it's the complete 'address' for a specific connection. Think of it as a phone call: the IP is the building's phone number, the port is the extension, and the socket is the actual open line between two people.
Real Talk
A socket is an endpoint in a network communication identified by an IP address and port number. A connection is uniquely defined by a 4-tuple: (source IP, source port, destination IP, destination port). Sockets can be TCP (stream) or UDP (datagram).
Show Me The Code
// Node.js TCP socket example
const net = require('net');
const client = new net.Socket();
client.connect(80, 'example.com', () => {
console.log('Connected via socket!');
client.write('GET / HTTP/1.0\r\n\r\n');
});
client.on('data', (data) => console.log(data.toString()));
When You'll Hear This
"The server listens on a socket for incoming connections." / "WebSockets are different from regular TCP sockets."
Related Terms
IP Address
An IP address is your device's home address on the internet.
Port
A port is like an apartment number on a building. Your computer is the building (localhost), and multiple services live inside.
TCP (Transmission Control Protocol)
TCP is like sending a package with delivery confirmation.
WebSocket
WebSocket is like upgrading a walkie-talkie from push-to-talk to a full phone call.