From 784041f5b99ba28252c9bb67a5bfb4a5da41ef93 Mon Sep 17 00:00:00 2001 From: Steven McCoy Date: Mon, 8 Aug 2011 12:10:31 +0200 Subject: ZMQ_IPV4ONLY option added At this point option exists, is documented and can be set, however, it has no effect. Signed-off-by: Steven McCoy Signed-off-by: Martin Sustrik --- src/options.cpp | 25 +++++++++++++++++++++++++ src/options.hpp | 5 +++++ 2 files changed, 30 insertions(+) (limited to 'src') diff --git a/src/options.cpp b/src/options.cpp index 45eb4aa..89cf429 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -40,6 +40,7 @@ zmq::options_t::options_t () : maxmsgsize (-1), rcvtimeo (-1), sndtimeo (-1), + ipv4only (1), delay_on_close (true), delay_on_disconnect (true), filter (false) @@ -179,6 +180,21 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, sndtimeo = *((int*) optval_); return 0; + case ZMQ_IPV4ONLY: + { + if (optvallen_ != sizeof (int)) { + errno = EINVAL; + return -1; + } + int val = *((int*) optval_); + if (val != 0 && val != 1) { + errno = EINVAL; + return -1; + } + ipv4only = val; + return 0; + } + } errno = EINVAL; @@ -333,6 +349,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) *optvallen_ = sizeof (int); return 0; + case ZMQ_IPV4ONLY: + if (*optvallen_ < sizeof (int)) { + errno = EINVAL; + return -1; + } + *((int*) optval_) = ipv4only; + *optvallen_ = sizeof (int); + return 0; + } errno = EINVAL; diff --git a/src/options.hpp b/src/options.hpp index d8847f5..4689522 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -78,6 +78,11 @@ namespace zmq int rcvtimeo; int sndtimeo; + // If 1, indicates the use of IPv4 sockets only, it will not be + // possible to communicate with IPv6-only hosts. If 0, the socket can + // connect to and accept connections from both IPv4 and IPv6 hosts. + int ipv4only; + // If true, session reads all the pending messages from the pipe and // sends them to the network when socket is closed. bool delay_on_close; -- cgit v1.2.3