Sockets, TCP & WebSockets
What is a socket?
A socket is a software communication endpoint. A TCP connection has two endpoints, each associated with an IP address and port.
Is a socket just an IP and port?
An IP address and port identify an endpoint. A TCP connection is identified by both local and remote endpoint addresses and ports, plus the transport protocol.
What is TCP?
TCP provides a reliable, ordered byte stream. It does not preserve application message boundaries: reads may return part of a write or combine multiple writes.
What does HTTP do?
HTTP is an application-layer protocol with defined request and response semantics. HTTP/1.1 and HTTP/2 commonly run over TCP; HTTP/3 runs over QUIC.
What is WebSocket?
WebSocket provides a persistent, full-duplex channel between client and server, typically established through an HTTP handshake.
What is Socket.IO?
Socket.IO is an event-based library with features such as reconnection and fallbacks. It is not the same protocol as raw WebSocket.
When should I use them?
Use HTTP for typical request/response APIs. Consider WebSockets or Socket.IO for chat, live dashboards, collaboration or other timely two-way updates.
Related: Browse all topics