diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-09-24 18:38:14 +0200 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-09-24 18:42:22 +0200 |
commit | 817d26b81df7028ff8bcb8690dae0cec1319b63a (patch) | |
tree | df16a1c92f3dd4c9e68d18fda2b423477c2c5d2e /example.c | |
parent | 81f6b8ffd42460038e3b9498e7a60347eef1fcd4 (diff) |
Use context variable to keep state for a connection
The context supports both blocking and non-blocking connections. All
read and write events are not handled by hiredis, but hiredis exposes an
API for buffered reading/writing to Redis.
Diffstat (limited to 'example.c')
-rw-r--r-- | example.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -5,13 +5,13 @@ #include "hiredis.h" int main(void) { - int fd; + redisContext *fd; unsigned int j; redisReply *reply; - reply = redisConnect(&fd, "127.0.0.1", 6379); - if (reply != NULL) { - printf("Connection error: %s", reply->reply); + fd = redisConnect((char*)"127.0.0.1", 6379, NULL); + if (fd->error != NULL) { + printf("Connection error: %s", ((redisReply*)fd->error)->reply); exit(1); } |