From ec41f6540f6dfc7bae2eff2581a692db304bc41c Mon Sep 17 00:00:00 2001 From: Constantin Rack Date: Fri, 13 Nov 2015 10:44:53 +0100 Subject: [PATCH] Problem: tcp_recv/send_buffer should be byte value instead of scale factor Solution: change option behaviour and adopt documentation --- doc/zmq_getsockopt.txt | 14 ++++++-------- doc/zmq_setsockopt.txt | 14 ++++++-------- src/options.cpp | 15 ++++++++------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/doc/zmq_getsockopt.txt b/doc/zmq_getsockopt.txt index fb7583f6..be322475 100644 --- a/doc/zmq_getsockopt.txt +++ b/doc/zmq_getsockopt.txt @@ -738,10 +738,9 @@ Applicable socket types:: all, when using TCP transport ZMQ_TCP_RECV_BUFFER: Size of the TCP receive buffer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The 'ZMQ_RECV_BUFFER' specifies the maximum number of bytes which can -be received by an individual syscall to receive data from the TCP -socket. The buffer size is specified as an integer number from 0 (very small) -to 10 (very large). The default value is 3. +The 'ZMQ_TCP_RECV_BUFFER' specifies the maximum number of bytes which can +be received by an individual syscall to receive data from the TCP socket. +The default value is 8192. [horizontal] @@ -752,10 +751,9 @@ Applicable socket types:: all, when using TCP transport ZMQ_TCP_SEND_BUFFER: Size of the TCP receive buffer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The 'ZMQ_SEND_BUFFER' specifies the maximum number of bytes which can -be sent by an individual syscall to transmit data to the TCP -socket. The buffer size is specified as an integer number from 0 (very small) -to 10 (very large). The default value is 3. +The 'ZMQ_TCP_SEND_BUFFER' specifies the maximum number of bytes which can +be sent by an individual syscall to transmit data to the TCP socket. +The default value is 8192. [horizontal] diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt index 9921b12d..95a7aff8 100644 --- a/doc/zmq_setsockopt.txt +++ b/doc/zmq_setsockopt.txt @@ -1073,10 +1073,9 @@ Applicable socket types:: all, when using TCP transports. ZMQ_TCP_RECV_BUFFER: Size of the TCP receive buffer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The 'ZMQ_RECV_BUFFER' specifies the maximum number of bytes which can -be received by an individual syscall to receive data from the TCP -socket. The buffer size is specified as an integer number from 0 (very small) -to 10 (very large). The default value is 3. +The 'ZMQ_TCP_RECV_BUFFER' specifies the maximum number of bytes which can +be received by an individual syscall to receive data from the TCP socket. +The default value is 8192. [horizontal] @@ -1087,10 +1086,9 @@ Applicable socket types:: all, when using TCP transport ZMQ_TCP_SEND_BUFFER: Size of the TCP receive buffer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The 'ZMQ_SEND_BUFFER' specifies the maximum number of bytes which can -be sent by an individual syscall to transmit data to the TCP -socket. The buffer size is specified as an integer number from 0 (very small) -to 10 (very large). The default value is 3. +The 'ZMQ_TCP_SEND_BUFFER' specifies the maximum number of bytes which can +be sent by an individual syscall to transmit data to the TCP socket. +The default value is 8192. [horizontal] diff --git a/src/options.cpp b/src/options.cpp index c89d3a02..1ea66435 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -28,7 +28,6 @@ */ #include -#include #include "options.hpp" #include "err.hpp" @@ -66,8 +65,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), + tcp_recv_buffer_size (8192), + tcp_send_buffer_size (8192), mechanism (ZMQ_NULL), as_server (0), gss_plaintext (false), @@ -284,14 +283,16 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, break; case ZMQ_TCP_RECV_BUFFER: - if (is_int && (value >= 0 && value <= 10) ) { - tcp_recv_buffer_size = static_cast(std::pow(2.0, value)) * 1024; + if (is_int && (value > 0) ) { + tcp_recv_buffer_size = static_cast(value); + return 0; } break; case ZMQ_TCP_SEND_BUFFER: - if (is_int && (value >= 0 && value <= 10) ) { - tcp_send_buffer_size = static_cast(std::pow(2.0, value)) * 1024; + if (is_int && (value > 0) ) { + tcp_send_buffer_size = static_cast(value); + return 0; } break;