[zeromq-dev] full duplex asynch messaging
Arun Jayaprakash
arun.jaiprakash at gmail.com
Mon Mar 15 14:28:30 CET 2010
Ahh, i think that might be close to what i was looking for. Thanks a lot!
Is there any tutorial/example on similar lines (reactor/proactor) ?
Rgds
Arun
On Mon, Mar 15, 2010 at 5:23 PM, Martin Sustrik <sustrik at 250bpm.com> wrote:
> Arun,
>
>
> I didnt really mean the API differences (which as you point out,
>> differ only by a loop). However, as i explained, i have to use this same
>> socket for sending too. Then the code becomes queue<msg_t> outgoing queue;
>> void recv_thread_routine ()
>> {
>> socket_t s (ctx, ZMQ_SUB);
>> s.connect (...);
>> while (true) {
>> message_t msg;
>> s.recv (&msg);
>> callback (msg);
>> acquire lock on outgoingqueue then if (outgoingQueue not empty)
>> dequeue and send contents()
>> }
>> }
>>
>> Is this the only design possible?
>>
>
> The above won't work. You can't send messages to SUB socket.
>
> However, if you have a bi-directional socket (such as P2P), you can poll
> for IN & OUT and do the send/recv depending on the result.
>
> Martin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100315/b1669a79/attachment.htm>
More information about the zeromq-dev
mailing list