erickt / rust-zmq

Rust zeromq bindings.
Apache License 2.0
886 stars 189 forks source link

Question on poll integration via mio crate #350

Closed TomzBench closed 1 year ago

TomzBench commented 1 year ago

I am using udev crate and it uses mio to read a socket for an event. Is it possible to use mio crate to poll the underlying zmq socket when the socket is readable? This is something zmq normally uses poll items for, however i would prefer polling with the mio crate if possible.

TomzBench commented 1 year ago

It looks likq zmq_getsockopt(ZMQ_SOCKFD, ...) can be used to get the underlying file handle which explicitly says can be used to integrate with an existing event loop! http://api.zeromq.org/master:zmq-getsockopt

The socket.get_fd returns a RawFd which has a Source impl in MIO and allows it to be polled...