A socket is a communication endpoint identified by an IP address and port number pair. A TCP connection is uniquely identified by a 5-tuple: (protocol, src IP, src port, dst IP, dst port). Applications create sockets to send and receive data – the OS manages the underlying protocol state.
A socket is the programming abstraction for network communication. The Berkeley sockets API (socket, bind, listen, accept, connect, send, recv) is the foundation of all network programming on Unix and Windows. A listening server socket binds to a port and accepts incoming connections, creating a new connected socket for each client. Each connected socket represents one conversation. A server on port 80 can handle thousands of simultaneous connections because each is uniquely identified by the full 5-tuple, not just the local port. Socket buffers in the kernel hold data between the network and the application – the receive buffer fills when data arrives faster than the application reads, and the send buffer queues data until the network can transmit it.
Packet
A packet is a unit of data transmitted over a network. Each packet contains a header (source/destination addresses, protocol info, sequence numbers) and a payload (the actual data). IP packets are limited by MTU – typically 1500 bytes on Ethernet. Larger messages are split into multiple packets.
MTU (Maximum Transmission Unit)
MTU is the largest packet size a network link can carry without fragmentation. Ethernet MTU is 1500 bytes. If a packet exceeds the path MTU, it is fragmented (IPv4) or dropped with ICMP Packet Too Big (IPv6). Path MTU Discovery (PMTUD) finds the lowest MTU along a route.