• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

Applications need a way to access network services (TCP, UDP) without implementing protocol internals. An interface is needed to allow applications to send/receive data over the network.

Core Idea

An application programming interface that provides a set of functions for applications to use network services, acting as the Service Access Point between the application and transport layers.

How It Works

  1. Application calls socket() to create a socket endpoint
  2. Calls bind() to assign local address/port (server) or connect() to initiate connection (client)
  3. Uses send()/recv() (or write()/read()) to exchange data
  4. Calls close() to terminate the connection
  5. Server uses listen() and accept() to handle incoming connections

Visual Explanation

G App Application API Socket API socket(), connect(), send(), recv(), close() App->API Service Primitives Transport Transport Layer (TCP/UDP) API->Transport Layer Interface

Key Properties

  • Standardized interface across operating systems (Berkeley sockets, Winsock)
  • Hides protocol details from applications
  • Supports both connection-oriented (TCP) and connectionless (UDP) sockets
  • File descriptor-based (sockets behave like files)

Connections

Edge Cases & Gotchas

  • Blocking vs non-blocking sockets: blocking waits, non-blocking returns immediately
  • Socket descriptor leaks if close() isn’t called (resource exhaustion)
  • Different socket types: stream (TCP), datagram (UDP), raw sockets