In the c API, connections are asynchronous, meaning after calling zookeeper_unit your global handler will first receive a connecting state and then a connected state event.
So. You'd not want to assume that a connected state preceded by a connecting state means any type of connection failure. It sounds like you may want to consider leader election of zknodes in your application instead of using session events to guess when your zkclients are connected. Michael Sent from my iPhone On Aug 16, 2010, at 3:29 PM, Goran Zuzic <zuza...@facebook.com> wrote: > Hi! I just started using Zookeeper so excuse my dumb question :) > > I'm developing an zookeeper client that allows only one instance of an > application to run at a time. It is not so good if two applications run at > the same time. > As a precaution, I made my client shut down the application whenever it > receives CONNECTING_STATE (for instance, if I can't reach the zookeeper > ensamble due to a cable cut, I won't receive any other notification so I just > shut down as a precaution). > > So my question would be: if everything runs smoothly, will I ever receive a > CONNECTING_STATE trigger? For instance, it would be bad if there is a > CONNECTING_STATE that sometimes precedes CONNECTED_STATE even if everything > is connected and within timeouts. > > Hope I made sense, > Goran > >