diff options
Diffstat (limited to 'docs/libcurl/curl_easy_recv.3')
-rw-r--r-- | docs/libcurl/curl_easy_recv.3 | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/docs/libcurl/curl_easy_recv.3 b/docs/libcurl/curl_easy_recv.3 index 8a758d5d3..b42a64644 100644 --- a/docs/libcurl/curl_easy_recv.3 +++ b/docs/libcurl/curl_easy_recv.3 @@ -5,7 +5,7 @@ .\" * | (__| |_| | _ <| |___ .\" * \___|\___/|_| \_\_____| .\" * -.\" * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. +.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * .\" * This software is licensed as described in the file COPYING, which .\" * you should have received as part of this distribution. The terms @@ -60,7 +60,22 @@ read which would include any cached data. Furthermore if you wait on the socket and it tells you there is data to read, \fIcurl_easy_recv(3)\fP may return \fBCURLE_AGAIN\fP if the only data that was read was for internal SSL processing, and no other data is available. +.SH EXAMPLE +.nf + curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); + /* Do not do the transfer - only connect to host */ + curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L); + res = curl_easy_perform(curl); + + if(res == CURLE_OK) { + /* Extract the socket from the curl handle - + we'll need it for waiting. */ + res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd); + /* read data */ + res = curl_easy_recv(curl, buf, sizeof(buf), &nread); + } +.fi .SH AVAILABILITY Added in 7.18.2. .SH RETURN VALUE @@ -76,8 +91,6 @@ Reading exactly 0 bytes indicates a closed connection. If there's no socket available to use from the previous transfer, this function returns \fBCURLE_UNSUPPORTED_PROTOCOL\fP. -.SH EXAMPLE -See \fBsendrecv.c\fP in \fBdocs/examples\fP directory for usage example. .SH "SEE ALSO" .BR curl_easy_setopt "(3), " curl_easy_perform "(3), " .BR curl_easy_getinfo "(3), " |