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/ip.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/ip.hpp') diff --git a/src/ip.hpp b/src/ip.hpp index 9487303..da1fe84 100644 --- a/src/ip.hpp +++ b/src/ip.hpp @@ -28,9 +28,15 @@ namespace xs { // Same as socket(2), but allows for transparent tweaking the options. + // These functions automatically tune the socket so there's no need to + // call tune_socket/tune_tcp_socket afterwards. fd_t open_socket (int domain_, int type_, int protocol_); + fd_t open_tcp_socket (int domain_, bool keepalive_); - // Tunes the supplied TCP socket for the best latency. + // Tunes the supplied socket. Use these functions if you've got + // the socket in some other way, not by open_socket/open_tcp_socket + // (e.g. using accept()). + void tune_socket (fd_t s_); void tune_tcp_socket (fd_t s_, bool keeaplive_); // Sets the socket into non-blocking mode. -- cgit v1.2.3