summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/zmq_getsockopt.txt4
-rw-r--r--doc/zmq_setsockopt.txt4
-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
6 files changed, 25 insertions, 27 deletions
diff --git a/doc/zmq_getsockopt.txt b/doc/zmq_getsockopt.txt
index f2ad575..749d14e 100644
--- a/doc/zmq_getsockopt.txt
+++ b/doc/zmq_getsockopt.txt
@@ -159,7 +159,7 @@ in effect. For details refer to your operating system documentation for the
'SO_SNDBUF' socket option.
[horizontal]
-Option value type:: uint64_t
+Option value type:: int
Option value unit:: bytes
Default value:: 0
Applicable socket types:: all
@@ -173,7 +173,7 @@ in effect. For details refer to your operating system documentation for the
'SO_RCVBUF' socket option.
[horizontal]
-Option value type:: uint64_t
+Option value type:: int
Option value unit:: bytes
Default value:: 0
Applicable socket types:: all
diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt
index 3cf3276..0d1de3d 100644
--- a/doc/zmq_setsockopt.txt
+++ b/doc/zmq_setsockopt.txt
@@ -164,7 +164,7 @@ the OS default unchanged. For details please refer to your operating system
documentation for the 'SO_SNDBUF' socket option.
[horizontal]
-Option value type:: uint64_t
+Option value type:: int
Option value unit:: bytes
Default value:: 0
Applicable socket types:: all
@@ -178,7 +178,7 @@ OS default unchanged. For details refer to your operating system documentation
for the 'SO_RCVBUF' socket option.
[horizontal]
-Option value type:: uint64_t
+Option value type:: int
Option value unit:: bytes
Default value:: 0
Applicable socket types:: all
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 ();