build ssl example if ssl is enabled
This commit is contained in:
parent
4830786c84
commit
dc3c6ce85c
@ -37,5 +37,10 @@ IF (APPLE)
|
|||||||
TARGET_LINK_LIBRARIES(example-macosx hiredis ${CF})
|
TARGET_LINK_LIBRARIES(example-macosx hiredis ${CF})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
|
IF (HIREDIS_SSL)
|
||||||
|
ADD_EXECUTABLE(example-ssl example-ssl.c)
|
||||||
|
TARGET_LINK_LIBRARIES(example-ssl hiredis)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
ADD_EXECUTABLE(example example.c)
|
ADD_EXECUTABLE(example example.c)
|
||||||
TARGET_LINK_LIBRARIES(example hiredis)
|
TARGET_LINK_LIBRARIES(example hiredis)
|
@ -18,8 +18,12 @@ int main(int argc, char **argv) {
|
|||||||
const char *key = argv[4];
|
const char *key = argv[4];
|
||||||
const char *ca = argc > 4 ? argv[5] : NULL;
|
const char *ca = argc > 4 ? argv[5] : NULL;
|
||||||
|
|
||||||
struct timeval timeout = { 1, 500000 }; // 1.5 seconds
|
struct timeval tv = { 1, 500000 }; // 1.5 seconds
|
||||||
c = redisConnectWithTimeout(hostname, port, timeout);
|
redisOptions options = {0};
|
||||||
|
REDIS_OPTIONS_SET_TCP(&options, hostname, port);
|
||||||
|
options.timeout = &tv;
|
||||||
|
c = redisConnectWithOptions(&options);
|
||||||
|
|
||||||
if (c == NULL || c->err) {
|
if (c == NULL || c->err) {
|
||||||
if (c) {
|
if (c) {
|
||||||
printf("Connection error: %s\n", c->errstr);
|
printf("Connection error: %s\n", c->errstr);
|
||||||
|
Loading…
Reference in New Issue
Block a user