[zeromq-dev] How to detect if a remote socket has closed
Matt Weinstein
matt_weinstein at yahoo.com
Wed Aug 25 14:46:32 CEST 2010
I use ZMQ_PAIR to push stuff off my reactor thread, for example if I
have to steer certain message types. For example, if inbound and
outbound are the normal sockets, but there's something special that
has to be done with some of the client requests:
[[ INBOUND_REACTOR ]] >> { if (special) push to pair; else push to
outbound; }
[[ OUTBOUND_REACTOR ]] >> {push reply to inbound}
[[ PAIR_REACTOR ]] >> { e.g. send special reply to inbound }
Also, you can push off functions like updates, aggregation, command
and control etc., anything that has a stream at the other end from
which you'll need a streamed set of replies.
It's helpful to keep stuff off the reactor thread.
In addition, you can use pairs to speak to endpoint controls, e.g. if
you are brokering::
[[ INBOUND_REACTOR]] >> { request to pair(N) depending on type of
request, etc. }
[[ PAIR1_REACTOR ]] >> { push reply to inbound }
[[ PAIR2_REACTOR ]] >> { ibid }
...
Best,
Matt
On Aug 24, 2010, at 11:41 AM, <david.briant at ubs.com> <david.briant at ubs.com
> wrote:
> Just rereading this thread. Why shouldn't I be using pairs in normal
> code?
>
> I want to do simple point-to-point (often asynchronous) messaging
> between many peers. The REQ/REP and PUB/SUB paradigms don't fit.
> Additionally I want to do dynamic resource discovery which concretely
> binding to a port negates.
>
> Cheers
>
> David
>
> -----Original Message-----
> From: zeromq-dev-bounces at lists.zeromq.org
> [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Pieter
> Hintjens
> Sent: Tue 17-Aug-2010 17:05
> To: 0MQ development list
> Subject: Re: [zeromq-dev] How to detect if a remote socket has closed
>
> On Tue, Aug 17, 2010 at 5:04 PM, <David.Briant at ubs.com> wrote:
>
>> 1) Can I check that all socket types are meant to rebind
> automatically.
>
> All except ZMQ_PAIR, which you should not be using in normal code
> anyhow.
>
>> 2) Also the REQ socket appears to cause python to use 100% cpu if the
>> REP socket isn't running. I assume that shouldn't be the case?
>
> Definitely not healthy. So I just booted Windows XP and tried the
> Hello World client and server from the guide, in Python. Started the
> hwclient.py, watched CPU. Killed it, then started hwserver.py. In
> neither case was there any CPU usage (task manager itself takes 1% or
> so).
>
>> So it looks like I should have a directory service that can mediate
> PAIR
>> connections between peers, I need a SUB connection to the directory
> and
>> a REQ connection to initially connect to it on a well known port. The
>> directory a service is registered with PUBs any state changes such as
>> service crashes. It will also PUB a restart (of itself) on the same
>> channel. The only situation I don't have covered is if a directory
> crash
>> means the directory starting on a different IP but a slow heartbeat
>> mechanism should sort that.
>>
>> Do you recommend PGM for the PUB/SUB part? - initially there'll only
> be
>> a few apps so TCP might be fine.
>
> Don't take this the wrong way, but I'd really suggest you read through
> the user guide chapters 1 and 2 and work through all the examples
> until they are clear. They're all simple C programs.
>
> Then, start by solving a small part of your problem and get that
> working. Then, extend that carefully one piece at a time.
>
> -
> Pieter Hintjens
> iMatix - www.imatix.com
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> Visit our website at http://www.ubs.com
>
> This message contains confidential information and is intended only
> for the individual named. If you are not the named addressee you
> should not disseminate, distribute or copy this e-mail. Please
> notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system.
>
> E-mails are not encrypted and cannot be guaranteed to be secure or
> error-free as information could be intercepted, corrupted, lost,
> destroyed, arrive late or incomplete, or contain viruses. The sender
> therefore does not accept liability for any errors or omissions in the
> contents of this message which arise as a result of e-mail
> transmission.
> If verification is required please request a hard-copy version. This
> message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities
> or related financial instruments.
>
> UBS Limited is a company registered in England & Wales under company
> number 2035362, whose registered office is at 1 Finsbury Avenue,
> London, EC2M 2PP, United Kingdom.
>
> UBS AG (London Branch) is registered as a branch of a foreign company
> under number BR004507, whose registered office is at
> 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>
> UBS Clearing and Execution Services Limited is a company registered
> in England & Wales under company number 03123037, whose registered
> office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
>
> UBS reserves the right to retain all messages. Messages are protected
> and accessed only in legally justified cases.
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
More information about the zeromq-dev
mailing list