[zeromq-dev] polling in jeromq

Yu Dongmin miniway at gmail.com
Thu Jul 18 23:59:40 CEST 2013


Hi,

You need to call poller.poll(timeout) before you call poller.pollin

Thanks
Min

On Jul 19, 2013, at 12:10 AM, ashwini ramamurthy <ashwini.ram21 at gmail.com> wrote:

> Hi ,
> 
> I am learning to use zeromq polling in android . I am polling on a req socket and a sub socket in the android program(client). So that this client can receive both reply messages from the server and also published messages.
> 
> My polling is not working. Both the req socket and the publish socket does not get polled in. If i don't use polling both the sockets receive the message. 
> 
> I tried searching online but could not find anything relevant. 
> 
> The client code is this :
> 
> 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 i missing out something or doing something wrong? I don't get any errors. 
> 
> Thanks
> Ashwini
> 
> 
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130719/38662520/attachment.htm>


More information about the zeromq-dev mailing list