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 <steven.mccoy@miru.hk>
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
Steven McCoy
2011-08-08 12:10:31 +02:00
committed by Martin Sustrik
parent 8378180cbb
commit 784041f5b9
6 changed files with 64 additions and 4 deletions

View File

@@ -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;