Added UNIX socket support.

master
Nicolas Favre-Felix 14 years ago
parent 39487d29fb
commit e971eb4d26

@ -90,6 +90,7 @@ typedef struct redisAsyncContext {
/* Functions that proxy to hiredis */ /* Functions that proxy to hiredis */
redisAsyncContext *redisAsyncConnect(const char *ip, int port); redisAsyncContext *redisAsyncConnect(const char *ip, int port);
redisAsyncContext *redisAsyncConnectUnix(const char *path);
int redisAsyncSetReplyObjectFunctions(redisAsyncContext *ac, redisReplyObjectFunctions *fn); int redisAsyncSetReplyObjectFunctions(redisAsyncContext *ac, redisReplyObjectFunctions *fn);
int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn); int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn);
int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn); int redisAsyncSetDisconnectCallback(redisAsyncContext *ac, redisDisconnectCallback *fn);

@ -69,7 +69,12 @@ main(int argc, char *argv[]) {
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
#endif #endif
redisAsyncContext *c = redisAsyncConnect(cfg->redis_host, cfg->redis_port); redisAsyncContext *c = NULL;
if(cfg->redis_host[0] == '/') { /* unix socket */
c = redisAsyncConnectUnix(cfg->redis_host);
} else {
c = redisAsyncConnect(cfg->redis_host, cfg->redis_port);
}
if(c->err) { if(c->err) {
/* Let *c leak for now... */ /* Let *c leak for now... */
printf("Error: %s\n", c->errstr); printf("Error: %s\n", c->errstr);

Loading…
Cancel
Save