Graph
Socket

🔌Socket

NEW

Also known as: Network Socket, Communication Endpoint

An endpoint for bidirectional network communication between processes, identified by an IP address and port with a chosen transport protocol.

DESCRIPTION

Sockets provide a standard API for network communication between processes across machines or on the same host. They encapsulate addressing, ports, and transport protocols like TCP and UDP. Developers use sockets directly or via higher-level abstractions such as RPC frameworks and HTTP libraries. Concepts like blocking versus nonblocking I/O, multiplexing, and timeouts affect performance and reliability. Secure communication typically layers TLS over sockets. Unix domain sockets offer low-latency IPC on the same host. Proper error handling and backpressure management are essential in production systems.

ALTERNATIVE DEFINITIONS

Oracle

A socket is one endpoint of a two-way communication link between two programs running on the network.

Classic, widely cited definition emphasizing two-way communication.

Source

Microsoft Learn

A socket is an endpoint of a two-way communications link between two programs running on the network.

Consistent OS-level definition focused on Winsock API.

Source

TCP UDP Port IP Address Protocol WebSocket gRPC Transport Layer API

COMPETING TERMS

Queue RPC

KNOWLEDGE AREAS

Software Engineering Infrastructure Real-time & Streaming Data

TARGET AUDIENCE

Software Developer DevOps Engineer Cloud Architect Data Engineer

EXTERNAL SOURCES

TOP QUESTIONS

When should I use raw Sockets instead of HTTP libraries?

Use sockets for custom protocols, high-performance streaming, or specialized latency requirements. Otherwise, HTTP/gRPC abstractions speed development.

Category: Requirements

What’s the difference between TCP and UDP Sockets?

TCP provides reliable, ordered delivery with congestion control; UDP offers low-latency, connectionless communication without guarantees.

Category: Misunderstanding

How do I secure Socket communication?

Wrap sockets with TLS (e.g., TLS over TCP). Validate certificates, enforce modern ciphers, and manage key rotation.

Category: Requirements

What is nonblocking I/O with Sockets?

Nonblocking sockets return immediately if no data is available, enabling multiplexing through select, epoll, or IOCP for scalability.

Category: Example

What are common Socket programming mistakes?

Ignoring partial reads/writes, failing to handle timeouts, and not implementing backpressure can cause stalls or data loss.

Category: Mistakes

How do WebSockets relate to Sockets?

WebSockets are a higher-level protocol layered on TCP that enables full-duplex communication over a single connection.

Category: Misunderstanding

What is a port in Socket terms?

A port identifies a logical endpoint for a specific service on a host, combined with an IP address to route traffic.

Category: Example

Are Unix domain Sockets faster than TCP?

For local IPC, Unix domain sockets typically have lower latency and overhead than TCP loopback.

Category: Opinion

What performance risks exist in Socket servers?

Blocking calls and per-connection threads reduce scalability. Use event loops, backpressure, and connection pooling.

Category: Risks