Commit f7b933f5 authored by Juha Reunanen's avatar Juha Reunanen

LIBZMQ-195 allow explicitly setting sndbuf and rcvbuf to 0 (see…

LIBZMQ-195 allow explicitly setting sndbuf and rcvbuf to 0 (see https://support.microsoft.com/en-us/kb/201213)
parent 6ab66ca5
......@@ -41,8 +41,8 @@ zmq::options_t::options_t () :
rate (100),
recovery_ivl (10000),
multicast_hops (1),
sndbuf (0),
rcvbuf (0),
sndbuf (-1),
rcvbuf (-1),
tos (0),
type (-1),
linger (-1),
......
......@@ -196,14 +196,14 @@ int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_)
{
const int rcvbuf = (int) options.rcvbuf;
if (rcvbuf) {
if (rcvbuf >= 0) {
if (!pgm_setsockopt (sock, SOL_SOCKET, SO_RCVBUF, &rcvbuf,
sizeof (rcvbuf)))
goto err_abort;
}
const int sndbuf = (int) options.sndbuf;
if (sndbuf) {
if (sndbuf >= 0) {
if (!pgm_setsockopt (sock, SOL_SOCKET, SO_SNDBUF, &sndbuf,
sizeof (sndbuf)))
goto err_abort;
......
......@@ -340,9 +340,9 @@ int zmq::socks_connecter_t::connect_to_proxy ()
unblock_socket (s);
// Set the socket buffer limits for the underlying socket.
if (options.sndbuf != 0)
if (options.sndbuf >= 0)
set_tcp_send_buffer (s, options.sndbuf);
if (options.rcvbuf != 0)
if (options.rcvbuf >= 0)
set_tcp_receive_buffer (s, options.rcvbuf);
// Set the IP Type-Of-Service for the underlying socket
......
......@@ -258,9 +258,9 @@ int zmq::tcp_connecter_t::open ()
unblock_socket (s);
// Set the socket buffer limits for the underlying socket.
if (options.sndbuf != 0)
if (options.sndbuf >= 0)
set_tcp_send_buffer (s, options.sndbuf);
if (options.rcvbuf != 0)
if (options.rcvbuf >= 0)
set_tcp_receive_buffer (s, options.rcvbuf);
// Set the IP Type-Of-Service for the underlying socket
......
......@@ -207,9 +207,9 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
set_ip_type_of_service (s, options.tos);
// Set the socket buffer limits for the underlying socket.
if (options.sndbuf != 0)
if (options.sndbuf >= 0)
set_tcp_send_buffer (s, options.sndbuf);
if (options.rcvbuf != 0)
if (options.rcvbuf >= 0)
set_tcp_receive_buffer (s, options.rcvbuf);
// Allow reusing of the address.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment