* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * 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
* 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>
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;
}
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;
}
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;
}
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));