mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 03:20:13 +01:00
ZMQ_MONITOR socket option registers a callback / event sink for changes in socket state
This commit is contained in:
@@ -53,6 +53,7 @@ zmq::options_t::options_t () :
|
||||
tcp_keepalive_cnt (-1),
|
||||
tcp_keepalive_idle (-1),
|
||||
tcp_keepalive_intvl (-1),
|
||||
monitor (NULL),
|
||||
socket_id (0)
|
||||
{
|
||||
}
|
||||
@@ -313,6 +314,20 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
case ZMQ_MONITOR:
|
||||
{
|
||||
if (optvallen_ == 0 && optval_ == NULL) {
|
||||
monitor = NULL;
|
||||
return 0;
|
||||
}
|
||||
if (optvallen_ != sizeof (void *)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
monitor = ((zmq_monitor_fn*) optval_);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
@@ -530,6 +545,14 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
||||
*optvallen_ = last_endpoint.size()+1;
|
||||
return 0;
|
||||
|
||||
case ZMQ_MONITOR:
|
||||
if (*optvallen_ < sizeof (void *)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
((zmq_monitor_fn*) optval_) = monitor;
|
||||
*optvallen_ = sizeof (void *);
|
||||
return 0;
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user