summaryrefslogtreecommitdiff
path: root/src/tcp_connecter.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-13 06:32:24 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-14 04:59:27 +0200
commitf34f71bbd5b9b00b295aa6438dd251845547225c (patch)
treee5a84ab763991bea17a0aa66ab2c11d12c340f06 /src/tcp_connecter.cpp
parent048f8816f6bea585b092b528b9da648a32a9c94c (diff)
Set options on new sockets in systematic manner
This patch consolidates the up-to-now scattered code that sets different options on newly created sockets. There are open_socket and open_tcp_socket functions that do the tuning automatically. In case the socket is not created but got from elsewhere (such as accept() call) there are tune_socket and tune_tcp_socket functions that will do the tuning. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/tcp_connecter.cpp')
-rw-r--r--src/tcp_connecter.cpp11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/tcp_connecter.cpp b/src/tcp_connecter.cpp
index 8072209..2fbbff6 100644
--- a/src/tcp_connecter.cpp
+++ b/src/tcp_connecter.cpp
@@ -107,8 +107,6 @@ void xs::tcp_connecter_t::out_event (fd_t fd_)
return;
}
- tune_tcp_socket (fd, options.keepalive ? true : false);
-
// Create the engine object for this connection.
stream_engine_t *engine = new (std::nothrow) stream_engine_t (fd, options);
alloc_assert (engine);
@@ -207,16 +205,9 @@ int xs::tcp_connecter_t::open ()
xs_assert (s == retired_fd);
// Create the socket.
- s = open_socket (address.family (), SOCK_STREAM, IPPROTO_TCP);
-#ifdef XS_HAVE_WINDOWS
- if (s == INVALID_SOCKET) {
- wsa_error_to_errno ();
- return -1;
- }
-#else
+ s = open_tcp_socket (address.family (), options.keepalive ? true : false);
if (s == -1)
return -1;
-#endif
// On some systems, IPv4 mapping in IPv6 sockets is disabled by default.
// Switch it on in such cases.