﻿# TCP Fast Open connect can defer the first SYN

Account for cookie-dependent connection behavior and the first-write trigger when integrating TCP_FASTOPEN_CONNECT into an asynchronous client.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/tcp-fastopen-connect-fallback-boundary/
Language: en

## The connection looks complete before a packet leaves

An asynchronous client enables TCP_FASTOPEN_CONNECT, calls connect and then waits for a server greeting before writing its request. With a cached Fast Open cookie, this can stall without any network outage. The API can return before sending the initial SYN because transmission is deferred until data is supplied. The client has created a dependency cycle: it waits for a peer that has not yet received the opening exchange.

## Cookie presence changes the path

The [Linux TCP manual](https://man7.org/linux/man-pages/man7/tcp.7.html) distinguishes destinations with and without a cached cookie. Without one, connection establishment sends a SYN and requests a cookie through the Fast Open option. With one, connect can return immediately while a later write or send operation triggers SYN with data. Preserve whether the test was a first contact or a warmed destination. Repeated runs may therefore exercise different paths even when every visible application setting is unchanged.

## Integrate the first-write trigger explicitly

Treat connect return, first payload submission and transport establishment as distinct events in the client state machine. The documented sequence requires the write after connect for the cookie-present path. A blocking read-first client can wait indefinitely under that condition; a nonblocking client can repeatedly find no data without causing the missing initial transmission. An event loop should not assume that every successful connect has already performed the same network exchange as ordinary TCP establishment.

## Keep option and fallback policy visible

The [kernel IP configuration reference](https://docs.kernel.org/networking/ip-sysctl.html) documents separate Fast Open controls and black-hole handling policy. Record effective client settings, actual peer support and relevant cache state rather than equating option availability with use on the wire. The TCP manual also distinguishes the socket-option approach from using the Fast Open send flag directly. Do not mix both mechanisms casually or assume that a fallback observed on one destination establishes how another connection behaved.

## Acceptance needs cold and warm cases

In an approved isolated integration, test initial contact, a destination with an available cookie, unsupported or rejected Fast Open behavior and normal fallback where applicable. Capture connect outcome, first write, handshake evidence and correct application response. Use a bounded deadline so an invalid read-first dependency cannot hide as an endless network test. Acceptance should show the client handles every supported path without claiming a startup-latency improvement that was not actually measured under comparable cache conditions.

## Preserve application semantics

A transport optimization does not make an early request safe to replay or certify that the server committed application work. Keep application retry and duplication rules separate from connection setup. The [small-write guide](/journal/guide-net-tcp-nagle/) addresses buffering after data exists, while [zero-window diagnosis](/journal/guide-net-tcp-zero-window/) concerns an established peer's receiving capacity. Here the critical distinction comes earlier: a successful connect return can precede the first SYN, so useful connection progress depends on the client's documented first-write behavior.
