aboutsummaryrefslogtreecommitdiff
path: root/docs/examples/sendrecv.c
diff options
context:
space:
mode:
authorMarcel Raad <Marcel.Raad@teamviewer.com>2019-05-21 10:44:16 +0200
committerMarcel Raad <Marcel.Raad@teamviewer.com>2019-05-22 10:06:21 +0200
commit10b7067eb722bf2bc19f4dd6d97199be705baea2 (patch)
treed6a5e6ff76b923997ab6f859ac3d1015e9c30f81 /docs/examples/sendrecv.c
parent918987a844912b431f132b5c4d49fb73a0cb1a0e (diff)
examples: reduce variable scopes
Closes https://github.com/curl/curl/pull/3919
Diffstat (limited to 'docs/examples/sendrecv.c')
-rw-r--r--docs/examples/sendrecv.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/docs/examples/sendrecv.c b/docs/examples/sendrecv.c
index cf764be43..5660a7955 100644
--- a/docs/examples/sendrecv.c
+++ b/docs/examples/sendrecv.c
@@ -59,12 +59,9 @@ static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
int main(void)
{
CURL *curl;
- CURLcode res;
/* Minimalistic http request */
const char *request = "GET / HTTP/1.0\r\nHost: example.com\r\n\r\n";
size_t request_len = strlen(request);
- curl_socket_t sockfd;
- size_t nsent_total = 0;
/* A general note of caution here: if you're using curl_easy_recv() or
curl_easy_send() to implement HTTP or _any_ other protocol libcurl
@@ -76,6 +73,10 @@ int main(void)
curl = curl_easy_init();
if(curl) {
+ CURLcode res;
+ curl_socket_t sockfd;
+ size_t nsent_total = 0;
+
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);