summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/options.cpp22
-rw-r--r--src/options.hpp5
-rw-r--r--src/tcp_socket.cpp15
-rw-r--r--src/tcp_socket.hpp2
4 files changed, 21 insertions, 23 deletions
diff --git a/src/options.cpp b/src/options.cpp
index a053048..4c1289a 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -87,7 +87,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
return 0;
case ZMQ_RECOVERY_IVL:
- if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) < 0) {
+ if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) < 0) {
errno = EINVAL;
return -1;
}
@@ -95,19 +95,19 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
return 0;
case ZMQ_SNDBUF:
- if (optvallen_ != sizeof (uint64_t)) {
+ if (optvallen_ != sizeof (int) || *((int*) optval_) < 0) {
errno = EINVAL;
return -1;
}
- sndbuf = *((uint64_t*) optval_);
+ sndbuf = *((int*) optval_);
return 0;
case ZMQ_RCVBUF:
- if (optvallen_ != sizeof (uint64_t)) {
+ if (optvallen_ != sizeof (int) || *((int*) optval_) < 0) {
errno = EINVAL;
return -1;
}
- rcvbuf = *((uint64_t*) optval_);
+ rcvbuf = *((int*) optval_);
return 0;
case ZMQ_LINGER:
@@ -215,21 +215,21 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
return 0;
case ZMQ_SNDBUF:
- if (*optvallen_ < sizeof (uint64_t)) {
+ if (*optvallen_ < sizeof (int)) {
errno = EINVAL;
return -1;
}
- *((uint64_t*) optval_) = sndbuf;
- *optvallen_ = sizeof (uint64_t);
+ *((int*) optval_) = sndbuf;
+ *optvallen_ = sizeof (int);
return 0;
case ZMQ_RCVBUF:
- if (*optvallen_ < sizeof (uint64_t)) {
+ if (*optvallen_ < sizeof (int)) {
errno = EINVAL;
return -1;
}
- *((uint64_t*) optval_) = rcvbuf;
- *optvallen_ = sizeof (uint64_t);
+ *((int*) optval_) = rcvbuf;
+ *optvallen_ = sizeof (int);
return 0;
case ZMQ_TYPE:
diff --git a/src/options.hpp b/src/options.hpp
index 8b5864e..1699c1a 100644
--- a/src/options.hpp
+++ b/src/options.hpp
@@ -45,8 +45,9 @@ namespace zmq
// Reliability time interval [ms]. Default 10 seconds.
uint32_t recovery_ivl;
- uint64_t sndbuf;
- uint64_t rcvbuf;
+ // SO_SNDBUF and SO_RCVBUF to be passed to underlying transport sockets.
+ int sndbuf;
+ int rcvbuf;
// Socket type.
int type;
diff --git a/src/tcp_socket.cpp b/src/tcp_socket.cpp
index f1b1d19..924b0b0 100644
--- a/src/tcp_socket.cpp
+++ b/src/tcp_socket.cpp
@@ -35,22 +35,21 @@ zmq::tcp_socket_t::~tcp_socket_t ()
close ();
}
-int zmq::tcp_socket_t::open (fd_t fd_, uint64_t sndbuf_, uint64_t rcvbuf_)
+int zmq::tcp_socket_t::open (fd_t fd_, int sndbuf_, int rcvbuf_)
{
zmq_assert (s == retired_fd);
s = fd_;
if (sndbuf_) {
- int sz = (int) sndbuf_;
int rc = setsockopt (s, SOL_SOCKET, SO_SNDBUF,
- (char*) &sz, sizeof (int));
+ (char*) &sndbuf_, sizeof (int));
errno_assert (rc == 0);
}
if (rcvbuf_) {
int sz = (int) rcvbuf_;
int rc = setsockopt (s, SOL_SOCKET, SO_RCVBUF,
- (char*) &sz, sizeof (int));
+ (char*) &rcvbuf_, sizeof (int));
errno_assert (rc == 0);
}
@@ -145,20 +144,18 @@ zmq::tcp_socket_t::~tcp_socket_t ()
close ();
}
-int zmq::tcp_socket_t::open (fd_t fd_, uint64_t sndbuf_, uint64_t rcvbuf_)
+int zmq::tcp_socket_t::open (fd_t fd_, int sndbuf_, int rcvbuf_)
{
assert (s == retired_fd);
s = fd_;
if (sndbuf_) {
- int sz = (int) sndbuf_;
- int rc = setsockopt (s, SOL_SOCKET, SO_SNDBUF, &sz, sizeof (int));
+ int rc = setsockopt (s, SOL_SOCKET, SO_SNDBUF, &sndbuf_, sizeof (int));
errno_assert (rc == 0);
}
if (rcvbuf_) {
- int sz = (int) rcvbuf_;
- int rc = setsockopt (s, SOL_SOCKET, SO_RCVBUF, &sz, sizeof (int));
+ int rc = setsockopt (s, SOL_SOCKET, SO_RCVBUF, &rcvbuf_, sizeof (int));
errno_assert (rc == 0);
}
diff --git a/src/tcp_socket.hpp b/src/tcp_socket.hpp
index 3cb5739..3312605 100644
--- a/src/tcp_socket.hpp
+++ b/src/tcp_socket.hpp
@@ -37,7 +37,7 @@ namespace zmq
~tcp_socket_t ();
// Associates a socket with a native socket descriptor.
- int open (fd_t fd_, uint64_t sndbuf_, uint64_t rcvbuf_);
+ int open (fd_t fd_, int sndbuf_, int rcvbuf_);
// Closes the underlying socket.
int close ();