本文整理汇总了C++中redisContextConnectTcp函数的典型用法代码示例。如果您正苦于以下问题:C++ redisContextConnectTcp函数的具体用法?C++ redisContextConnectTcp怎么用?C++ redisContextConnectTcp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redisContextConnectTcp函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: redisContextInit
redisContext *redisConnectNonBlock(const char *ip, int port) {
redisContext *c;
c = redisContextInit();
if (c == NULL)
return NULL;
c->flags &= ~REDIS_BLOCK;
redisContextConnectTcp(c,ip,port,NULL);
return c;
}
开发者ID:creativeprogramming,项目名称:nchan,代码行数:11,代码来源:hiredis.c
示例2: redisContextInit
redisContext *redisConnectNonBlock(const char *ip, int port, int ssl, char* certfile, char* certdir) {
redisContext *c;
c = redisContextInit();
if (c == NULL)
return NULL;
c->flags &= ~REDIS_BLOCK;
if( ssl ) {
setupSSL();
redisContextConnectSSL(c,ip,port,certfile,certdir,NULL);
} else {
redisContextConnectTcp(c,ip,port,NULL);
}
return c;
}
开发者ID:bbroerman30,项目名称:ssl-redis,代码行数:18,代码来源:hiredis.c
示例3: redisContextInit
/* Connect to a Redis instance. On error the field error in the returned
* context will be set to the return value of the error function.
* When no set of reply functions is given, the default set will be used. */
redisContext *redisConnect(const char *ip, int port) {
redisContext *c = redisContextInit();
c->flags |= REDIS_BLOCK;
redisContextConnectTcp(c,ip,port,NULL);
return c;
}
开发者ID:esromneb,项目名称:hiredis,代码行数:9,代码来源:hiredis.c
示例4: libssh2_init
redisContext *redisConnect(const char *ip, int port, const char *ssh_address, int ssh_port, const char *username, const char *password,
const char *public_key, const char *private_key, const char *passphrase, int curMethod) {
LIBSSH2_SESSION *session = NULL;
if(ssh_address && curMethod != SSH_UNKNOWN){
int rc = libssh2_init(0);
if (rc != 0) {
return NULL;
}
struct sockaddr_in sin;
/* Connect to SSH server */
int sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
sin.sin_family = AF_INET;
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(ssh_address))) {
return NULL;
}
sin.sin_port = htons(ssh_port);
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
return NULL;
}
/* Create a session instance */
session = libssh2_session_init();
if(!session) {
return NULL;
}
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
rc = libssh2_session_handshake(session, sock);
if(rc) {
return NULL;
}
int auth_pw = 0;
libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
char *userauthlist = libssh2_userauth_list(session, username, strlen(username));
if (strstr(userauthlist, "password") != NULL) {
auth_pw |= 1;
}
if (strstr(userauthlist, "keyboard-interactive") != NULL) {
auth_pw |= 2;
}
if (strstr(userauthlist, "publickey") != NULL) {
auth_pw |= 4;
}
if (auth_pw & 1 && curMethod == SSH_PASSWORD) {
/* We could authenticate via password */
if (libssh2_userauth_password(session, username, password)) {
//"Authentication by password failed!";
return NULL;
}
}
else if (auth_pw & 2) {
/* Or via keyboard-interactive */
if (libssh2_userauth_keyboard_interactive(session, username, &kbd_callback) )
{
//"Authentication by keyboard-interactive failed!";
return NULL;
}
}
else if (auth_pw & 4 && curMethod == SSH_PUBLICKEY) {
/* Or by public key */
if (libssh2_userauth_publickey_fromfile(session, username, public_key, private_key, passphrase)){
//"Authentication by public key failed!";
return NULL;
}
}
else {
//"No supported authentication methods found!";
return NULL;
}
}
redisContext *c;
c = redisContextInit();
if (c == NULL)
return NULL;
c->session = session;
c->flags |= REDIS_BLOCK;
redisContextConnectTcp(c,ip,port,NULL);
return c;
}
开发者ID:TakedWind,项目名称:fastoredis,代码行数:90,代码来源:hiredis.c
示例5: redisContextInit
redisContext *redisConnectNonBlock(const char *ip, int port) {
redisContext *c = redisContextInit();
c->flags &= ~REDIS_BLOCK;
redisContextConnectTcp(c,ip,port);
return c;
}
开发者ID:sidorares,项目名称:redis-server-gem,代码行数:6,代码来源:hiredis.c
注:本文中的redisContextConnectTcp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论