summaryrefslogtreecommitdiff
path: root/src/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/options.cpp')
-rw-r--r--src/options.cpp25
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;