From f34f71bbd5b9b00b295aa6438dd251845547225c Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 13 Apr 2012 06:32:24 +0200 Subject: 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 --- src/tcp_connecter.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src/tcp_connecter.cpp') 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. -- cgit v1.2.3