summaryrefslogtreecommitdiff
path: root/src/ip.hpp
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/ip.hpp
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/ip.hpp')
-rw-r--r--src/ip.hpp8
1 files changed, 7 insertions, 1 deletions
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.