Protocols
Saved & recent

Socket

Also called: network socket, listening socket, connected socket, socket API

A socket is a software endpoint through which an application uses communication services supplied by the operating system. Its address family and type determine how it behaves: an Internet stream socket commonly uses TCP, while a datagram socket commonly uses UDP. A socket is an API object, not a physical connector or just a port number.

For example, a TCP server binds a listening socket to a local address and port, then accepts an incoming connection. The accept operation returns a separate connected socket used to exchange bytes with that client. The listening socket can continue accepting other clients. Several connections can share the server’s port because their complete endpoint combinations distinguish them.

Read first
Transport port
Related
TCP, UDP, WebSocket
Further reading
Python 3.15 socket documentation — Socket Objects
server host TCP :8000 listening socket retained 192.0.2.10:51000 application bytes · client 1 accept → new socket :8000 192.0.2.10:51000 192.0.2.11:51001 application bytes · client 2 accept → new socket :8000 192.0.2.11:51001 distinct connected sockets
Illustrative server API: one listening socket accepts clients and returns a separate connected socket for each connection.

View in the full Protocols collection