summaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-09-24 18:38:14 +0200
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-09-24 18:42:22 +0200
commit817d26b81df7028ff8bcb8690dae0cec1319b63a (patch)
treedf16a1c92f3dd4c9e68d18fda2b423477c2c5d2e /example.c
parent81f6b8ffd42460038e3b9498e7a60347eef1fcd4 (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.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/example.c b/example.c
index c3f1473..96283c6 100644
--- a/example.c
+++ b/example.c
@@ -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);
}