aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/examples/externalsocket.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/docs/examples/externalsocket.c b/docs/examples/externalsocket.c
index 0ac113db3..d89b041b4 100644
--- a/docs/examples/externalsocket.c
+++ b/docs/examples/externalsocket.c
@@ -124,8 +124,10 @@ int main(void)
servaddr.sin_port = htons(PORTNUM);
servaddr.sin_addr.s_addr = inet_addr(IPADDR);
- if(INADDR_NONE == servaddr.sin_addr.s_addr)
+ if(INADDR_NONE == servaddr.sin_addr.s_addr) {
+ close(sockfd);
return 2;
+ }
if(connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) ==
-1) {
@@ -157,10 +159,16 @@ int main(void)
curl_easy_cleanup(curl);
+ close(sockfd);
+
if(res) {
printf("libcurl error: %d\n", res);
return 4;
}
}
+
+#ifdef WIN32
+ WSACleanup();
+#endif
return 0;
}