Well, there are few missed points here:
First, a ZeroMQ-Socket
-instance is not anything like an O/S socket. For principal disambiguation, feel free to read posts on conceptual differences.
This is an often re-articulated misconception, so let me repeat it in bold.
Beware: ZeroMQ Socket()
-instance is not a tcp-socket-as-you-know-it. Best read about the main conceptual differences in [ ZeroMQ hierarchy in less than a five seconds ] or other posts and discussions here
The ZMQ_NOBLOCK
symbol can be used in more places:
the zmq_recv()
being one such, zmq_send()
being another.
This symbol is principaly #define
-ed in header file, but somewhere having also some other value-identical aliases, a zmq.DONTWAIT
being one such flag
-composition related symbol for python-wrappers/bindings.
The Socket
-instance has no such property as (not-)being blocking:
this is the core principal miss in your so far posted questions.
The Socket
-instance does not persist any such feature per-se.
The respective ( individual ) instance operation - a call to a { .recv() | .send() }
-method can use a parameter-based mechanism to change it's per-call modus operandi:
flags = { 0, ZMQ_DONTWAIT, ZMQ_SENDMORE, ZMQ_DONTWAIT && ZMQ_SENDMORE }
but having no such option to "turn"-any-such mode on/off to persist.
Q: "Is there a way to set the socket itself as Non-Blocking"?
A: No.
Q: "Is there a way to set the Poller.poll()
to return immediately"?
A: YES!
int zmq_poll ( zmq_pollitem_t *items, int nitems,
long timeout
);
so,
unless one calls zmq_poll( ..., -1 )
, which turns the polling hang indefinitely long, the zmq_poll()
-call returns as late as timeout
[ms]
, so using timeout == 0
, the zmq_poll()
-call returns immediately, whether there has been found any item or not, that's great, isn't it?