summaryrefslogtreecommitdiff
path: root/src/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/options.cpp')
-rw-r--r--src/options.cpp49
1 files changed, 45 insertions, 4 deletions
diff --git a/src/options.cpp b/src/options.cpp
index 952907b..75821da 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdio.h>
#include <string.h>
#ifndef ZMQ_HAVE_WINDOWS
#include <sys/stat.h>
@@ -44,7 +45,9 @@ zmq::options_t::options_t () :
backlog (100),
requires_in (false),
requires_out (false),
- immediate_connect (true)
+ immediate_connect (true),
+ rcvtimeo (-1),
+ sndtimeo (-1)
{
}
@@ -68,7 +71,11 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
// Check that SWAP directory (.) is writable
struct stat stat_buf;
- if (stat (".", &stat_buf) || ((stat_buf.st_mode & S_IWRITE) == 0)) {
+#if (ZMQ_HAVE_ANDROID || ZMQ_HAVE_LINUX)
+ if (stat (".", &stat_buf) || ((stat_buf.st_mode & S_IWUSR) == 0)) {
+#else
+ if (stat (".", &stat_buf) || ((stat_buf.st_mode & S_IWRITE) == 0)) {
+#endif
errno = EACCES;
return -1;
}
@@ -103,7 +110,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
rate = (uint32_t) *((int64_t*) optval_);
return 0;
-
+
case ZMQ_RECOVERY_IVL:
if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) < 0) {
errno = EINVAL;
@@ -191,6 +198,22 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
backlog = *((int*) optval_);
return 0;
+ case ZMQ_RCVTIMEO:
+ if (optvallen_ != sizeof (int)) {
+ errno = EINVAL;
+ return -1;
+ }
+ rcvtimeo = *((int*) optval_);
+ return 0;
+
+ case ZMQ_SNDTIMEO:
+ if (optvallen_ != sizeof (int)) {
+ errno = EINVAL;
+ return -1;
+ }
+ sndtimeo = *((int*) optval_);
+ return 0;
+
}
errno = EINVAL;
@@ -246,7 +269,7 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
*((int64_t*) optval_) = rate;
*optvallen_ = sizeof (int64_t);
return 0;
-
+
case ZMQ_RECOVERY_IVL:
if (*optvallen_ < sizeof (int64_t)) {
errno = EINVAL;
@@ -337,6 +360,24 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
*optvallen_ = sizeof (int);
return 0;
+ case ZMQ_RCVTIMEO:
+ if (*optvallen_ < sizeof (int)) {
+ errno = EINVAL;
+ return -1;
+ }
+ *((int*) optval_) = rcvtimeo;
+ *optvallen_ = sizeof (int);
+ return 0;
+
+ case ZMQ_SNDTIMEO:
+ if (*optvallen_ < sizeof (int)) {
+ errno = EINVAL;
+ return -1;
+ }
+ *((int*) optval_) = sndtimeo;
+ *optvallen_ = sizeof (int);
+ return 0;
+
}
errno = EINVAL;