New options to set send/recv buffer size for TCP sockets.

This commit is contained in:
Jens Auer
2015-10-08 22:06:33 +02:00
committed by Jens Auer
parent c41fe88df6
commit cdeec4c115
6 changed files with 101 additions and 12 deletions

View File

@@ -28,6 +28,7 @@
*/
#include <string.h>
#include <cmath>
#include "options.hpp"
#include "err.hpp"
@@ -65,6 +66,8 @@ zmq::options_t::options_t () :
tcp_keepalive_cnt (-1),
tcp_keepalive_idle (-1),
tcp_keepalive_intvl (-1),
tcp_recv_buffer_size (3),
tcp_send_buffer_size (3),
mechanism (ZMQ_NULL),
as_server (0),
gss_plaintext (false),
@@ -280,6 +283,18 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
}
break;
case ZMQ_TCP_RECV_BUFFER:
if (is_int && (value >= 0 && value <= 10) ) {
tcp_send_buffer_size = static_cast<int>(std::pow(2, value)) * 1024;
}
break;
case ZMQ_TCP_SEND_BUFFER:
if (is_int && (value >= 0 && value <= 10) ) {
tcp_send_buffer_size = static_cast<int>(std::pow(2, value)) * 1024;
}
break;
case ZMQ_IMMEDIATE:
if (is_int && (value == 0 || value == 1)) {
immediate = value;
@@ -790,6 +805,20 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
}
break;
case ZMQ_TCP_SEND_BUFFER:
if (is_int) {
*value = tcp_send_buffer_size;
return 0;
}
break;
case ZMQ_TCP_RECV_BUFFER:
if (is_int) {
*value = tcp_recv_buffer_size;
return 0;
}
break;
case ZMQ_MECHANISM:
if (is_int) {
*value = mechanism;