aboutsummaryrefslogtreecommitdiffstats
path: root/docs/examples/externalsocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/externalsocket.c')
-rw-r--r--docs/examples/externalsocket.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/docs/examples/externalsocket.c b/docs/examples/externalsocket.c
index 5486d125..9b144b42 100644
--- a/docs/examples/externalsocket.c
+++ b/docs/examples/externalsocket.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, 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
- * are also available at http://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -19,9 +19,10 @@
* KIND, either express or implied.
*
***************************************************************************/
-/*
- * This is an example demonstrating how an application can pass in a custom
+/* <DESC>
+ * An example demonstrating how an application can pass in a custom
* socket to libcurl to use. This example also handles the connect itself.
+ * </DESC>
*/
#include <stdio.h>
#include <string.h>
@@ -53,7 +54,7 @@
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
- int written = fwrite(ptr, size, nmemb, (FILE *)stream);
+ size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
return written;
}
@@ -91,7 +92,7 @@ int main(void)
WSADATA wsaData;
int initwsa;
- if((initwsa = WSAStartup(MAKEWORD(2,0), &wsaData)) != 0) {
+ if((initwsa = WSAStartup(MAKEWORD(2, 0), &wsaData)) != 0) {
printf("WSAStartup failed: %d\n", initwsa);
return 1;
}
@@ -106,7 +107,7 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
/* Create the socket "manually" */
- if( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) == CURL_SOCKET_BAD ) {
+ if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == CURL_SOCKET_BAD) {
printf("Error creating listening socket.\n");
return 3;
}
@@ -115,10 +116,10 @@ int main(void)
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(PORTNUM);
- if (INADDR_NONE == (servaddr.sin_addr.s_addr = inet_addr(IPADDR)))
+ if(INADDR_NONE == (servaddr.sin_addr.s_addr = inet_addr(IPADDR)))
return 2;
- if(connect(sockfd,(struct sockaddr *) &servaddr, sizeof(servaddr)) ==
+ if(connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) ==
-1) {
close(sockfd);
printf("client error: connect: %s\n", strerror(errno));