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  - TCP
11Added-in: 7.49.0
12---
13
14# NAME
15
16CURLOPT_TCP_FASTOPEN - TCP Fast Open
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_FASTOPEN, long enable);
24~~~
25
26# DESCRIPTION
27
28Pass a long as parameter set to 1L to enable or 0 to disable.
29
30TCP Fast Open (RFC 7413) is a mechanism that allows data to be carried in the
31SYN and SYN-ACK packets and consumed by the receiving end during the initial
32connection handshake, saving up to one full round-trip time (RTT).
33
34Beware: the TLS session cache does not work when TCP Fast Open is enabled. TCP
35Fast Open is also known to be problematic on or across certain networks.
36
37# DEFAULT
38
390
40
41# %PROTOCOLS%
42
43# EXAMPLE
44
45~~~c
46int main(void)
47{
48  CURL *curl = curl_easy_init();
49  if(curl) {
50    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
51    curl_easy_setopt(curl, CURLOPT_TCP_FASTOPEN, 1L);
52    curl_easy_perform(curl);
53  }
54}
55~~~
56
57# NOTES
58
59This option is only supported on Linux and macOS 10.11 or later.
60
61# %AVAILABILITY%
62
63# RETURN VALUE
64
65Returns CURLE_OK if fast open is supported by the operating system, otherwise
66returns CURLE_NOT_BUILT_IN.
67