* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, 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
#include <sys/types.h> /* socket types */
#include <sys/socket.h> /* socket definitions */
#include <netinet/in.h>
-#include <arpa/inet.h> /* inet (3) funtions */
+#include <arpa/inet.h> /* inet (3) functions */
#include <unistd.h> /* misc. Unix functions */
#endif
return written;
}
+static int closecb(void *clientp, curl_socket_t item)
+{
+ (void)clientp;
+ printf("libcurl wants to close %d now\n", (int)item);
+ return 0;
+}
+
static curl_socket_t opensocket(void *clientp,
curlsocktype purpose,
struct curl_sockaddr *address)
curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket);
curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd);
+ /* call this function to close sockets */
+ curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closecb);
+ curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &sockfd);
+
/* call this function to set options for the socket */
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);