zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 李赫元 <liheyuan...@gmail.com>
Subject How to know if connection to zk is successful in C API.
Date Mon, 14 May 2012 09:04:12 GMT
Hi All,

I encounter a problem in zookeeper 3.4.1 with C API.
The following is always show "success" even the zkserver is actually down.

    char* zk_server = "127.0.0.1:2181";
    zhandle_t* zh = zookeeper_init(zk_server, watcher_callback, 3000,
0, NULL, 0);
    if(!zh)
    {
        print_error(errno);
        return -1;
    }else
    {
        ::std::cout << "success" << ::std::endl;
    }

Even if the zookeeper is shutdown, the zh handle is still not NULL.
So, I don't know how to judge if connection to zookeeper is succful in C API.

Thanks all.

Heyuan Li

Mime
View raw message