aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.inc2
-rw-r--r--src/tool_cb_skt.c97
-rw-r--r--src/tool_cb_skt.h35
-rw-r--r--src/tool_operate.c18
4 files changed, 15 insertions, 137 deletions
diff --git a/src/Makefile.inc b/src/Makefile.inc
index 1660bc403..a43ac514c 100644
--- a/src/Makefile.inc
+++ b/src/Makefile.inc
@@ -22,7 +22,6 @@ CURL_CFILES = hugehelp.c \
tool_cb_prg.c \
tool_cb_rea.c \
tool_cb_see.c \
- tool_cb_skt.c \
tool_cb_wrt.c \
tool_cfgable.c \
tool_convert.c \
@@ -62,7 +61,6 @@ CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
tool_cb_prg.h \
tool_cb_rea.h \
tool_cb_see.h \
- tool_cb_skt.h \
tool_cb_wrt.h \
tool_cfgable.h \
tool_convert.h \
diff --git a/src/tool_cb_skt.c b/src/tool_cb_skt.c
deleted file mode 100644
index 156c1108e..000000000
--- a/src/tool_cb_skt.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2011, 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.
- *
- * 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
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-#include "setup.h"
-
-#include <curl/curl.h>
-
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-
-#define ENABLE_CURLX_PRINTF
-/* use our own printf() functions */
-#include "curlx.h"
-
-#include "tool_cfgable.h"
-#include "tool_msgs.h"
-#include "tool_cb_skt.h"
-
-#include "memdebug.h" /* keep this as LAST include */
-
-/*
-** callback for CURLOPT_SOCKOPTFUNCTION
-*/
-
-int tool_sockopt_cb(void *userdata, curl_socket_t curlfd, curlsocktype purpose)
-{
- struct Configurable *config = userdata;
-
- int onoff = 1; /* this callback is only used if we ask for keepalives on the
- connection */
-
-#if defined(TCP_KEEPIDLE) || defined(TCP_KEEPINTVL)
- int keepidle = (int)config->alivetime;
-#endif
-
- switch(purpose) {
- case CURLSOCKTYPE_IPCXN:
- if(setsockopt(curlfd, SOL_SOCKET, SO_KEEPALIVE, (void *)&onoff,
- sizeof(onoff)) < 0) {
- /* don't abort operation, just issue a warning */
- SET_SOCKERRNO(0);
- warnf(config, "Could not set SO_KEEPALIVE!\n");
- return 0;
- }
- else {
- if(config->alivetime) {
-#ifdef TCP_KEEPIDLE
- if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPIDLE, (void *)&keepidle,
- sizeof(keepidle)) < 0) {
- /* don't abort operation, just issue a warning */
- SET_SOCKERRNO(0);
- warnf(config, "Could not set TCP_KEEPIDLE!\n");
- return 0;
- }
-#endif
-#ifdef TCP_KEEPINTVL
- if(setsockopt(curlfd, IPPROTO_TCP, TCP_KEEPINTVL, (void *)&keepidle,
- sizeof(keepidle)) < 0) {
- /* don't abort operation, just issue a warning */
- SET_SOCKERRNO(0);
- warnf(config, "Could not set TCP_KEEPINTVL!\n");
- return 0;
- }
-#endif
-#if !defined(TCP_KEEPIDLE) || !defined(TCP_KEEPINTVL)
- warnf(config, "Keep-alive functionality somewhat crippled due to "
- "missing support in your operating system!\n");
-#endif
- }
- }
- break;
- default:
- break;
- }
-
- return 0;
-}
-
diff --git a/src/tool_cb_skt.h b/src/tool_cb_skt.h
deleted file mode 100644
index 11bd0c422..000000000
--- a/src/tool_cb_skt.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef HEADER_CURL_TOOL_CB_SKT_H
-#define HEADER_CURL_TOOL_CB_SKT_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2011, 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.
- *
- * 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
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-#include "setup.h"
-
-/*
-** callback for CURLOPT_SOCKOPTFUNCTION
-*/
-
-int tool_sockopt_cb(void *userdata,
- curl_socket_t curlfd,
- curlsocktype purpose);
-
-#endif /* HEADER_CURL_TOOL_CB_SKT_H */
-
diff --git a/src/tool_operate.c b/src/tool_operate.c
index e113ecdfc..1557e6256 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -41,6 +41,10 @@
# include <locale.h>
#endif
+#ifdef HAVE_NETINET_TCP_H
+# include <netinet/tcp.h>
+#endif
+
#include "rawstr.h"
#define ENABLE_CURLX_PRINTF
@@ -54,7 +58,6 @@
#include "tool_cb_prg.h"
#include "tool_cb_rea.h"
#include "tool_cb_see.h"
-#include "tool_cb_skt.h"
#include "tool_cb_wrt.h"
#include "tool_dirhie.h"
#include "tool_doswin.h"
@@ -1165,9 +1168,18 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
/* curl 7.17.1 */
if(!config->nokeepalive) {
- my_setopt(curl, CURLOPT_SOCKOPTFUNCTION, tool_sockopt_cb);
- my_setopt(curl, CURLOPT_SOCKOPTDATA, config);
+ my_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
+ if(config->alivetime != 0) {
+#if !defined(TCP_KEEPIDLE) || !defined(TCP_KEEPINTVL)
+ warnf(config, "Keep-alive functionality somewhat crippled due to "
+ "missing support in your operating system!\n");
+#endif
+ my_setopt(curl, CURLOPT_TCP_KEEPIDLE, config->alivetime);
+ my_setopt(curl, CURLOPT_TCP_KEEPINTVL, config->alivetime);
+ }
}
+ else
+ my_setopt(curl, CURLOPT_TCP_KEEPALIVE, 0L);
/* curl 7.20.0 */
if(config->tftp_blksize)