What is a Socket?
Socket communication, told as a story about a dedicated mailbox hole made from a house address and a room number.
Several people share one house.The house address alone can't tell apart who's inside.
Several programs talking at once get their letters tangled.The house address alone can't tell which letter belongs to which program's conversation.
A socket is a dedicated hole made from an address and a room number.In TCP, one connected socket hole carries that conversation from start to finish.
A socket sits at each end.The sender's IP+port and the receiver's IP+port together form the connection.
A socket is the hole — the envelope type is chosen when it's made.When a socket is opened, it's set up for registered envelopes (TCP) or plain ones (UDP).
A socket is a dedicated mailbox hole made from an IP address (which house) and a port number (which room), looking after one end of a conversation.
A socket is the endpoint the operating system provides for network communication, identified by the combination of an IP address and a port number (the socket address). A program creates a socket, gives it an address (bind) or links it to the other side (connect), then reads and writes data — a TCP socket behaves connection-oriented, a UDP socket connectionless. Multiple programs on the same host sharing one IP are still told apart as long as their port numbers differ.
When grown-ups say it
- Socket
- A dedicated hole made from an address and a room number. It marks one end of a connection.
- IP address
- The house address. Points to which computer it is.
- Port number
- The room number inside the house. Points to which program it is.
- TCP/UDP
- The registered envelope and the plain one. Choosing which envelope to send through the socket hole. → the registered envelope and the plain one
- bind/connect
- The steps that give the hole an address (bind) and link it to the other side (connect). The setup step before a socket can be used.
- Port conflict
- Trying to use a room number that's already taken. The same room number can't be reused at once.
- Firewall
- A wall with many doors. Sometimes blocks socket access by keeping only certain ports open. → the wall with many doors
- IPv6
- The far longer new house-address system. The house part of a socket address is moving to this system. → the new, nearly endless address system