Networking
Socket
Added: June 15, 2026Nurtured: June 20, 2026
Definition
A Socket is a communication endpoint created using an IP Address and a Port Number which allows two applications to exchange data.
What Problem It Solves
Sockets solve the complexity of low-level networking by abstracting the IP and Port details into a simple read/write file descriptor interface. It establishes a live, bidirectional communication line that developers can easily write to and read from in code.
What Happens If Not Used
Without sockets, developers would have to manually implement packet segmentation, TCP handshakes, checksum verifications, and state tracking for every network request they make.
Easy Wording
A socket is an open, live communication line between two programs.
Layman Example
Suppose:
Hotel Address = IP Address
Room Number = Port
Telephone Call = Socket
When call starts:
Hotel
↓
Room 443
↓
Phone Connected
↓
Conversation Begins
That's a socket.
Technical Example
You open https://google.com:
- DNS lookup:
google.com->142.250.xx.xx - Endpoint knowledge: Browser knows
IP: 142.250.xx.xx,Port: 443 - Socket creation: Browser creates a socket to
142.250.xx.xx:443 - TCP Handshake:
- Browser: "Can I connect?"
- Google: "Yes"
- Browser: "Let's communicate"
- Data Transfer:
- Browser sends
GET /through socket - Google responds with HTML page through socket
- Browser sends
- Connection Teardown: Browser closes the socket, ending the communication.