android - Using polling in jeromq -


i learning use zeromq polling in android . polling on req socket , sub socket in android program(client). client can receive both reply messages server , published messages.

my polling not working. both req socket , publish socket not polled in. if don't use polling both sockets receive message.

i tried searching online not find relevant. client code :

    public void run()    {     zmq.context context = zmq.context(1);     zmq.socket reqsocket = context.socket(zmq.req);     zmq.socket subsocket =context.socket(zmq.sub);     reqsocket.connect("tcp://10.186.3.174:8081");     subsocket.connect("tcp://10.186.3.174:8083");     subsocket.subscribe("".getbytes());     byte[] receivedmessage;     poller poller=context.poller();     poller.register(reqsocket,poller.pollin);     poller.register(subsocket,poller.pollin);      reqsocket.send(msg.getbytes(),0);       while(!thread.currentthread().isinterrupted())      {          if(poller.pollin(0))         {             receivedmessage=s.recv(0);          }           if(poller.pollin(0))           {             receivedmessage=subsocket.recv(0);            }    }     s.close();     context.term(); 

}

am missing out or doing wrong?

it looks there 3 problems this. main 1 need call poller.poll() first thing inside while loop. why not getting any messages.

the next issue you're checking same index both sockets: expect second if statement needs

if(poller.pollin(1)) 

lastly, req socket requires send before every receive, call send needs inside while loop, , before poller.poll() added above :)


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -