1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_TCP_NODELAY 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_BUFFERSIZE (3) 9 - CURLOPT_SOCKOPTFUNCTION (3) 10 - CURLOPT_TCP_KEEPALIVE (3) 11Protocol: 12 - All 13--- 14 15# NAME 16 17CURLOPT_TCP_NODELAY - the TCP_NODELAY option 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TCP_NODELAY, long nodelay); 25~~~ 26 27# DESCRIPTION 28 29Pass a long specifying whether the *TCP_NODELAY* option is to be set or 30cleared (1L = set, 0 = clear). The option is set by default. This has no 31effect after the connection has been established. 32 33Setting this option to 1L disables the Nagle algorithm on connections created 34using this handle. The purpose of this algorithm is to minimize the number of 35small packets on the network (where "small packets" means TCP segments less 36than the Maximum Segment Size for the network). 37 38Maximizing the amount of data sent per TCP segment is good because it 39amortizes the overhead of the send. However, in some cases small segments may 40need to be sent without delay. This is less efficient than sending larger 41amounts of data at a time, and can contribute to congestion on the network if 42overdone. 43 44# DEFAULT 45 461 47 48# EXAMPLE 49 50~~~c 51int main(void) 52{ 53 CURL *curl = curl_easy_init(); 54 if(curl) { 55 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 56 /* leave Nagle enabled */ 57 curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 0); 58 curl_easy_perform(curl); 59 } 60} 61~~~ 62 63# AVAILABILITY 64 65Always. The default was changed to 1 from 0 in 7.50.2. 66 67# RETURN VALUE 68 69Returns CURLE_OK 70