diff options
| author | antirez <antirez@gmail.com> | 2019-09-20 20:06:47 +0200 |
|---|---|---|
| committer | antirez <antirez@gmail.com> | 2019-09-20 20:08:38 +0200 |
| commit | c3899720f64e62920c7d90bc009afdca5824c087 (patch) | |
| tree | 933bf2a4ee9b4e8d5f82967b095943874ab2c332 /deps/hiredis/examples/example-libevent.c | |
| parent | 2e4fa7bb48875984c285a63475fbdb8b26e279f3 (diff) | |
| download | redis-c3899720f64e62920c7d90bc009afdca5824c087.tar.gz | |
hiredis updated to master version.
Diffstat (limited to 'deps/hiredis/examples/example-libevent.c')
| -rw-r--r-- | deps/hiredis/examples/example-libevent.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/deps/hiredis/examples/example-libevent.c b/deps/hiredis/examples/example-libevent.c index d333c22b7..1fe71ae4e 100644 --- a/deps/hiredis/examples/example-libevent.c +++ b/deps/hiredis/examples/example-libevent.c @@ -9,7 +9,12 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) { redisReply *reply = r; - if (reply == NULL) return; + if (reply == NULL) { + if (c->errstr) { + printf("errstr: %s\n", c->errstr); + } + return; + } printf("argv[%s]: %s\n", (char*)privdata, reply->str); /* Disconnect after receiving the reply to GET */ @@ -35,8 +40,14 @@ void disconnectCallback(const redisAsyncContext *c, int status) { int main (int argc, char **argv) { signal(SIGPIPE, SIG_IGN); struct event_base *base = event_base_new(); + redisOptions options = {0}; + REDIS_OPTIONS_SET_TCP(&options, "127.0.0.1", 6379); + struct timeval tv = {0}; + tv.tv_sec = 1; + options.timeout = &tv; + - redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379); + redisAsyncContext *c = redisAsyncConnectWithOptions(&options); if (c->err) { /* Let *c leak for now... */ printf("Error: %s\n", c->errstr); |
