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