[zeromq-dev] polling in jeromq
ashwini ramamurthy
ashwini.ram21 at gmail.com
Fri Jul 19 20:47:25 CEST 2013
Hi ,
Thanks,it worked. Could you please explain how it made a difference?
Doesn't poller.poll define a timeout so that it does not wait infinitely?
And also when i used polling in jzmq i did not use poller.poll() but it
still worked. Is this specific to jeromq?
Regards,
Ashwini
On Thu, Jul 18, 2013 at 5:59 PM, Yu Dongmin <miniway at gmail.com> wrote:
> 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
>
>
>
> _______________________________________________
> 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/36c311c4/attachment.htm>
More information about the zeromq-dev
mailing list