[zeromq-dev] Non-Blocking REQ/REP Server

Lee Sylvester lee.sylvester at gmail.com
Tue Feb 19 15:44:45 CET 2013


Hey guys,

So, I've integrated ØMQ into my server.  Now, I want to use ØMQ as a means to supply information to a HTTP server from a separate management app.  So, in theory, it will look something like this

int read_zmq_connections() {
    int ret = 0;
    while (zmq_has_messages(zmq_responder)) {
        char *str = s_recv(zmq_responder);
        parse_new_data(str);
        free(str);
        ++ret;
    }
    return ret;
}

This way, if there are no messages on zmq_responder, then the function will simply return.  What I don't know how to do (and can't quite find) is how to check if messages exist on the connection.  Can anyone please point me in the right direction?

The reason why I need this non-blocking is that I will only be calling 'read_zmq_connections' approximately once every five minutes and I don't want my app to hang while waiting for messages.

Thanks loads in advance,
Lee


More information about the zeromq-dev mailing list