xref: /curl/docs/libcurl/opts/CURLOPT_PIPEWAIT.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_PIPEWAIT
5Section: 3
6Source: libcurl
7See-also:
8  - CURLMOPT_MAX_HOST_CONNECTIONS (3)
9  - CURLMOPT_PIPELINING (3)
10  - CURLOPT_FORBID_REUSE (3)
11  - CURLOPT_FRESH_CONNECT (3)
12Protocol:
13  - HTTP
14Added-in: 7.43.0
15---
16
17# NAME
18
19CURLOPT_PIPEWAIT - wait for multiplexing
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PIPEWAIT, long wait);
27~~~
28
29# DESCRIPTION
30
31Set *wait* to 1L to tell libcurl to prefer to wait for a connection to
32confirm or deny that it can do multiplexing before continuing.
33
34When about to perform a new transfer that allows multiplexing, libcurl checks
35for existing connections to use. If no such connection exists it immediately
36continues and creates a fresh new connection to use.
37
38By setting this option to 1 - and having CURLMOPT_PIPELINING(3) enabled
39for the multi handle this transfer is associated with - libcurl instead waits
40for the connection to reveal if it is possible to multiplex on before it
41continues. This enables libcurl to much better keep the number of connections
42to a minimum when using multiplexing protocols.
43
44With this option set, libcurl prefers to wait and reuse an existing connection
45for multiplexing rather than the opposite: prefer to open a new connection
46rather than waiting.
47
48The waiting time is as long as it takes for the connection to get up and for
49libcurl to get the necessary response back that informs it about its protocol
50and support level.
51
52# DEFAULT
53
540 (off)
55
56# %PROTOCOLS%
57
58# EXAMPLE
59
60~~~c
61int main(void)
62{
63  CURL *curl = curl_easy_init();
64  if(curl) {
65    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
66    curl_easy_setopt(curl, CURLOPT_PIPEWAIT, 1L);
67
68    /* now add this easy handle to the multi handle */
69  }
70}
71~~~
72
73# %AVAILABILITY%
74
75# RETURN VALUE
76
77Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
78