mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-12 03:00:26 +09:00
Improve getai().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@726 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -89,23 +89,25 @@ static void sock_set_blocking(socket_t sock) {
|
|||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
static int getai(const char *host, int port, struct addrinfo **ai)
|
static int getai(const char *host, int port, struct addrinfo **ai) {
|
||||||
{
|
const char *service = NULL;
|
||||||
struct addrinfo hints;
|
struct addrinfo hints;
|
||||||
char *service=NULL;
|
|
||||||
char s_port[10];
|
char s_port[10];
|
||||||
|
|
||||||
memset(&hints,0,sizeof(hints));
|
ZERO_STRUCT(hints);
|
||||||
hints.ai_protocol=IPPROTO_TCP;
|
|
||||||
hints.ai_family=PF_UNSPEC;
|
hints.ai_protocol = IPPROTO_TCP;
|
||||||
hints.ai_socktype=SOCK_STREAM;
|
hints.ai_family = PF_UNSPEC;
|
||||||
if(port==0){
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_flags=AI_PASSIVE;
|
|
||||||
|
if (port == 0) {
|
||||||
|
hints.ai_flags = AI_PASSIVE;
|
||||||
} else {
|
} else {
|
||||||
snprintf(s_port,sizeof(s_port),"%hu",port);
|
snprintf(s_port, sizeof(s_port), "%hu", port);
|
||||||
service=s_port;
|
service = s_port;
|
||||||
}
|
}
|
||||||
return getaddrinfo(host,service,&hints,ai);
|
|
||||||
|
return getaddrinfo(host, service, &hints, ai);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ssh_connect_ai_timeout(SSH_SESSION *session, const char *host,
|
static int ssh_connect_ai_timeout(SSH_SESSION *session, const char *host,
|
||||||
|
|||||||
Reference in New Issue
Block a user