Skip to content

Socket

Medium — good to knowNetworking

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."

Made with passive-aggressive love by manoga.digital. Powered by Claude.