Add sockopt ZMQ_RCVTIMEO/ZMQ_SNDTIMEO.

- Add doc and tests
- Add options and setup
- Wait using poll/select

Signed-off-by: Fabien Ninoles <fabien@tzone.org>
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
Fabien Ninoles
2011-06-17 12:22:02 +02:00
committed by Martin Sustrik
parent 65d2b70312
commit d7923f08ca
16 changed files with 407 additions and 50 deletions

View File

@@ -39,6 +39,8 @@ zmq::options_t::options_t () :
backlog (100),
maxmsgsize (-1),
filter (1),
rcvtimeo (-1),
sndtimeo (-1),
immediate_connect (true)
{
}
@@ -182,6 +184,22 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
filter = *((int*) optval_);
return 0;
case ZMQ_RCVTIMEO:
if (optvallen_ != sizeof (int)) {
errno = EINVAL;
return -1;
}
rcvtimeo = *((int*) optval_);
return 0;
case ZMQ_SNDTIMEO:
if (optvallen_ != sizeof (int)) {
errno = EINVAL;
return -1;
}
sndtimeo = *((int*) optval_);
return 0;
}
errno = EINVAL;
@@ -336,6 +354,24 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
*optvallen_ = sizeof (int);
return 0;
case ZMQ_RCVTIMEO:
if (*optvallen_ < sizeof (int)) {
errno = EINVAL;
return -1;
}
*((int*) optval_) = rcvtimeo;
*optvallen_ = sizeof (int);
return 0;
case ZMQ_SNDTIMEO:
if (*optvallen_ < sizeof (int)) {
errno = EINVAL;
return -1;
}
*((int*) optval_) = sndtimeo;
*optvallen_ = sizeof (int);
return 0;
}
errno = EINVAL;