diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-03-28 09:20:38 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-03-28 09:20:38 +0200 |
commit | 9c7e081f51063b6cdb4674f4d2e6c4eab502a327 (patch) | |
tree | 25c46150eee45e6ad327b2e5e92fd8802fff72a5 /src/options.cpp | |
parent | e440e55d45a571c221af9c1657a2006597a6b88f (diff) |
XS_KEEPALIVE options added
This option allows to turn on TCP keepalives on the underlying connections.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/options.cpp')
-rw-r--r-- | src/options.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/options.cpp b/src/options.cpp index 2b123c2..07d3752 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -45,6 +45,7 @@ xs::options_t::options_t () : rcvtimeo (-1), sndtimeo (-1), ipv4only (1), + keepalive (0), delay_on_close (true), delay_on_disconnect (true), filter (false), @@ -216,6 +217,21 @@ int xs::options_t::setsockopt (int option_, const void *optval_, return 0; } + case XS_KEEPALIVE: + { + if (optvallen_ != sizeof (int)) { + errno = EINVAL; + return -1; + } + int val = *((int*) optval_); + if (val != 0 && val != 1) { + errno = EINVAL; + return -1; + } + keepalive = val; + return 0; + } + } errno = EINVAL; @@ -388,6 +404,15 @@ int xs::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) *optvallen_ = sizeof (int); return 0; + case XS_KEEPALIVE: + if (*optvallen_ < sizeof (int)) { + errno = EINVAL; + return -1; + } + *((int*) optval_) = keepalive; + *optvallen_ = sizeof (int); + return 0; + } errno = EINVAL; |