Networking & Internet
Socket
Definition
A network socket is an internal endpoint for sending or receiving data at a single node in a computer network. Concretely, it is a representation of this endpoint in networking software. It is a combination of an IP address and a port number.
Why It Matters
Sockets are the programming interface for network communication. When a developer wants to create a network application, they use the socket API provided by the operating system to create, connect, send, and receive data.
Contextual Example
A web server application creates a "listening socket" on port 80. When a client request arrives on that port, the server "accepts" the connection, which creates a new socket dedicated to communication with that specific client.
Common Misunderstandings
- A socket is defined by the combination of a protocol, a local IP address, a local port, a remote IP address, and a remote port.
- Socket programming is the fundamental way to write network-aware applications.