libzmq
libzmq copied to clipboard
[Question] ZMQ_SERVER; ending communication with only one client of many.
Issue description
In regards to ZMQ_SERVER, if a single client sends a bad frame and I want to end communication with the client, how do I do that without ending communication with all connected clients?
Environment
- libzmq version (commit hash if unreleased): v4.3.4
- OS: Windows
Seems like we need something like this?
// zmq.cpp
int zmq_drop_peer (void *s_, uint32_t routing_id, bool delay) {
zmq::server_t *s = static_cast<zmq::server_t *> (s_);
int socket_type;
size_t socket_type_size = sizeof (socket_type);
if (s->getsockopt (ZMQ_TYPE, &socket_type, &socket_type_size) != 0) {
errno = EINVAL;
return -1;
}
if (socket_type != ZMQ_PEER && socket_type != ZMQ_SERVER) {
errno = ENOTSUP;
return -1;
}
return s->drop(routing_id, delay);
}
// server.cpp
int zmq::server_t::drop(uint32_t routing_id, bool delay) {
out_pipes_t::iterator it = _out_pipes.find (routing_id);
if (it == _out_pipes.end ()) {
errno = EHOSTUNREACH;
return -1;
}
it->second.pipe->terminate (delay);
return 0;
}
Hello? FYI for anyone interested, the above code seems to work.
So this need a patch into the libzmq then? I would be very interested by this