Tech

Network Socket

Just as you plug a lamp into a wall outlet to get power, a network socket is the software plug that lets a program connect to the internet and start a conversation.

  • 3 min read
  • 1 figures
  • Verified 2026-10-13

Definition

A network socket is a virtual connection point that the operating system opens so a program on one computer can send and receive data with a program on another computer over a network.

Like Plugging Into a Wall Outlet

Picture plugging a lamp into a wall outlet. The moment the plug clicks in, invisible electricity flows and the lamp lights up. Programs need something similar to talk to other computers: a kind of virtual plug and outlet.

When you open a web browser or a messaging app, your computer's operating system creates a small software channel for it. That channel is the socket. The program doesn't need to know anything about cables or radio signals. It just pushes text or photos into the socket.

Then the operating system and the network hardware wrap up that data and carry it to the other computer. From the program's point of view, a socket is a handy mail slot. All it has to do is drop messages in and take them out.

Where an IP Address Meets a Port Number

To know where to connect, a socket needs two pieces of information put together: an IP address, which is like a building's street address, and a port number, which is like the apartment number inside that building.

Think of a big apartment complex. The IP address is the location of the building. The port number is the specific unit, like Apt 101 or Apt 202, where a package should be delivered. A socket acts as the private front door of one specific apartment.

For example, a web server usually opens sockets on port 80 or 443, which are reserved for web traffic, and waits for visitors. When your browser knocks on that socket's door, a private one-to-one phone line is set up between the two sides, and the conversation begins.

A Bit More Precisely: Connection-Based vs. Connectionless

Sockets work in two main ways, depending on what the communication is for. A stream socket (TCP) is like making a phone call: you first confirm the other person is on the line, then talk so that nothing gets lost or mixed up. A datagram socket (UDP) is like dropping a letter with just an address into a mailbox, quick and with no confirmation.

Things where no letter can go missing, such as web browsing or file transfers, have traditionally used reliable, connection-based sockets. These days, some web traffic (HTTP/3 and QUIC) runs on UDP, with reliability added on top. On the other hand, real-time games and video calls, where you'd rather lose a little data than wait even one second, mostly use the letter-dropping style.

When the conversation is over, the program closes the socket. Keeping a channel open uses up memory, so closing it gives resources back for the next new connection.

Common misconceptions

Myth

A network socket is the physical port on the back of a computer where you plug in an Ethernet cable.

Fact

It isn't a hardware jack. It's a virtual channel that the operating system creates in software so programs can exchange data over the internet.

Where you meet it

  1. When you leave a messaging app like WhatsApp open, a socket to the server stays open, so a new message shows up on your screen the moment it arrives.

  2. When you play an online game, your character's movement coordinates travel through a socket to the game server and other players dozens of times per second.

In one sentence

A network socket is a software connection point that lets a program talk to other programs over the internet.

Created 2026-03-06 Updated 2026-10-13 Verified 2026-10-13