docs: make all examples in all libcurl man pages compile

Closes #12448
This commit is contained in:
Daniel Stenberg 2023-12-04 10:50:42 +01:00
parent 3c4fba8cf5
commit cb521d1f9a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
478 changed files with 5989 additions and 3861 deletions

View file

@ -54,19 +54,27 @@ currently has no stored timeout value. You must not wait too long (more than a
few seconds perhaps) before you call \fIcurl_multi_perform(3)\fP again.
.SH EXAMPLE
.nf
struct timeval timeout;
long timeo;
int main(void)
{
struct timeval timeout;
long timeo;
fd_set fdread;
fd_set fdwrite;
fd_set fdexcep;
int maxfd;
CURLM *multi = curl_multi_init();
curl_multi_timeout(multi_handle, &timeo);
if(timeo < 0)
/* no set timeout, use a default */
timeo = 980;
curl_multi_timeout(multi, &timeo);
if(timeo < 0)
/* no set timeout, use a default */
timeo = 980;
timeout.tv_sec = timeo / 1000;
timeout.tv_usec = (timeo % 1000) * 1000;
timeout.tv_sec = timeo / 1000;
timeout.tv_usec = (timeo % 1000) * 1000;
/* wait for activities no longer than the set timeout */
select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout);
/* wait for activities no longer than the set timeout */
select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
}
.fi
.SH TYPICAL USAGE
Call \fIcurl_multi_timeout(3)\fP, then wait for action on the sockets. Figure