1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_TCP_FASTOPEN
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_SSL_FALSESTART (3)
9Protocol:
10  - All
11---
12
13# NAME
14
15CURLOPT_TCP_FASTOPEN - TCP Fast Open
16
17# SYNOPSIS
18
19~~~c
20#include <curl/curl.h>
21
22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_FASTOPEN, long enable);
23~~~
24
25# DESCRIPTION
26
27Pass a long as parameter set to 1L to enable or 0 to disable.
28
29TCP Fast Open (RFC 7413) is a mechanism that allows data to be carried in the
30SYN and SYN-ACK packets and consumed by the receiving end during the initial
31connection handshake, saving up to one full round-trip time (RTT).
32
33Beware: the TLS session cache does not work when TCP Fast Open is enabled. TCP
34Fast Open is also known to be problematic on or across certain networks.
35
36# DEFAULT
37
380
39
40# EXAMPLE
41
42~~~c
43int main(void)
44{
45  CURL *curl = curl_easy_init();
46  if(curl) {
47    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
48    curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L);
49    curl_easy_perform(curl);
50  }
51}
52~~~
53
54# AVAILABILITY
55
56Added in 7.49.0. This option is currently only supported on Linux and macOS
5710.11 or later.
58
59# RETURN VALUE
60
61Returns CURLE_OK if fast open is supported by the operating system, otherwise
62returns CURLE_NOT_BUILT_IN.
63