liveBook · Manning

TCP

As explained in Go in Practice, Second Edition

TCP is a connection-oriented transport-layer protocol that provides reliable, ordered byte streams.

TCP is a connection-oriented transport-layer protocol for reliable, ordered byte streams. In Go applications, it provides the network connection beneath many web and custom-server workloads, with built-in handshaking, error detection, acknowledgements, and reconnection support. section 7.2 section 7.0

A TCP exchange typically follows this operational pattern:

  • The application opens a connection between a client and server. section 7.2.2
  • The client sends messages through the connection, while TCP handles network-level responses that application code does not directly expose. section 7.2.2
  • TCP may split one application message across multiple packets; the receiver acknowledges each received packet. section 7.2.2
  • Applications must still address dropped connections and slow receivers, often by buffering data and making logging or delivery more resilient. section 7.2.2

Network logger

A logger opens a TCP connection to a remote logging service, sends log messages, and closes the connection. If the network or receiver fails, or transmission slows, buffering helps prevent lost messages and service failures. section 7.2.2

Figure 7.1 Sending messages over TCP, with a sequence of commands between a client (App) and server (Logger). First we connect; then an acknowledgement (Ack) is sent to the connection as well as to each message.
figure

Trace the client–server command sequence: connection establishment, acknowledgements for the connection and messages, and subsequent data exchange. section 7.2.2

TCP supports custom servers, log storage, and multiplexed communication. WebSockets extend persistent connections for longer-lived bidirectional exchanges, while standard HTTP remains the most common application approach over TCP. section 7.5

How Go in Practice, Second Edition covers it

How deep it goes
Explains connections, packets, acknowledgements, failures, and back pressure, but stops short of detailed network mechanics.
Examples
Uses a TCP network logger, packet acknowledgements, buffered delivery, and a client-server exchange diagram.
What it assumes
Assumes basic filesystem use and develops low-level networking outside Go’s standard net/http package.
What you can do after
Build custom TCP servers and diagnose delivery problems involving dropped connections, slow receivers, packet splitting, and acknowledgements.
How it connects
Connects TCP with TCP/IP, UDP, HTTP, WebSockets, server design, logging, buffering, and persistent connections.

Also explained in

Compare how 5 books explain TCP →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Go in Practice, Second Edition. The section links point to the parts of the book it draws on.