diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-04-13 06:32:24 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-04-14 04:59:27 +0200 |
commit | f34f71bbd5b9b00b295aa6438dd251845547225c (patch) | |
tree | e5a84ab763991bea17a0aa66ab2c11d12c340f06 /src/ip.hpp | |
parent | 048f8816f6bea585b092b528b9da648a32a9c94c (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.hpp | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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. |