|
Lines 2720-2735
Link Here
|
| 2720 |
static int |
2720 |
static int |
| 2721 |
connect_to(const char *host, u_short port) |
2721 |
connect_to(const char *host, u_short port) |
| 2722 |
{ |
2722 |
{ |
| 2723 |
struct addrinfo hints, *ai, *aitop; |
2723 |
struct addrinfo *ai, *aitop; |
| 2724 |
char ntop[NI_MAXHOST], strport[NI_MAXSERV]; |
2724 |
char ntop[NI_MAXHOST], strport[NI_MAXSERV]; |
| 2725 |
int gaierr; |
2725 |
int gaierr; |
| 2726 |
int sock = -1; |
2726 |
int sock = -1; |
| 2727 |
|
2727 |
|
| 2728 |
memset(&hints, 0, sizeof(hints)); |
|
|
| 2729 |
hints.ai_family = IPv4or6; |
| 2730 |
hints.ai_socktype = SOCK_STREAM; |
| 2731 |
snprintf(strport, sizeof strport, "%d", port); |
2728 |
snprintf(strport, sizeof strport, "%d", port); |
| 2732 |
if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) { |
2729 |
if ((gaierr = getaddrinfo(host, strport, NULL, &aitop)) != 0) { |
| 2733 |
error("connect_to %.100s: unknown host (%s)", host, |
2730 |
error("connect_to %.100s: unknown host (%s)", host, |
| 2734 |
gai_strerror(gaierr)); |
2731 |
gai_strerror(gaierr)); |
| 2735 |
return -1; |
2732 |
return -1; |