Skip to content
Latchkey

What Is a TCP Connection? Reliable Byte Streams

A TCP connection is a reliable, ordered channel between two endpoints, set up with a handshake, that guarantees bytes arrive intact and in order or the connection fails.

Most application protocols, including HTTP and gRPC, run on top of TCP. TCP turns the unreliable packet network into a dependable byte stream by acknowledging data, retransmitting losses, and ordering everything correctly. When a CI job reports a connection reset or timeout, it is a TCP-level failure underneath whatever protocol it was using.

The three-way handshake

A TCP connection opens with a SYN, SYN-ACK, ACK exchange that synchronizes both sides before any data flows. Only after the handshake completes can the application send bytes.

Reliable and ordered

TCP numbers bytes, acknowledges receipt, and retransmits anything lost, so the application sees a clean, in-order stream. This reliability is why it underpins so much traffic.

Ports identify endpoints

A connection is identified by source and destination IP plus port. A client opens an ephemeral local port to a well-known server port, like 443 for HTTPS.

How TCP errors appear in CI

  • Connection refused: nothing is listening on that port.
  • Connection reset: the peer dropped the connection mid-stream.
  • Connection timed out: no response within the deadline.

Connections and deploys

During a deploy, a backend restarting will refuse or reset connections until it is listening again. Health checks and retries smooth over this short window so callers do not see hard failures.

Transient resets in pipelines

A reset or timeout from a momentary blip is usually safe to retry on an idempotent request. Latchkey runners automatically retry these transient TCP-level failures to common endpoints so a single dropped connection does not fail a job.

Key takeaways

  • TCP provides a reliable, ordered byte stream set up with a three-way handshake.
  • Resets, refusals, and timeouts are the TCP-level errors behind many CI failures.
  • Transient resets on idempotent requests are generally safe to retry.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →