summaryrefslogtreecommitdiffhomepage
path: root/src/sock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sock.c')
-rw-r--r--src/sock.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/sock.c b/src/sock.c
index cefafd9..eefd75c 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -162,9 +162,11 @@ bind_socket_list (int sockfd, sblist *addresses, int family)
int opensock (const char *host, int port, const char *bind_to, const char *bind_to_alt)
{
int sockfd, n;
- struct ares_addrinfo hints, *res, *ressave;
+ struct ares_addrinfo *ressave;
+ struct ares_addrinfo_node *res;
+ struct ares_addrinfo_hints hints;
char portstr[6];
- ares_channel *resolver = NULL;
+ ares_channel resolver = NULL;
assert (host != NULL);
assert (port > 0);
@@ -190,7 +192,7 @@ int opensock (const char *host, int port, const char *bind_to, const char *bind_
snprintf (portstr, sizeof (portstr), "%d", port);
- n = ares_getaddrinfo (host, portstr, &hints, &res);
+ n = ares_getaddrinfo (resolver, host, portstr, &hints, &ressave);
if (n != 0) {
log_message (LOG_ERR,
"opensock: Could not retrieve address info for %s:%d: %s", host, port, get_gai_error (n));
@@ -200,7 +202,8 @@ int opensock (const char *host, int port, const char *bind_to, const char *bind_
log_message(LOG_INFO,
"opensock: getaddrinfo returned for %s:%d", host, port);
- ressave = res;
+ res = ressave->nodes;
+
do {
sockfd =
socket (res->ai_family, res->ai_socktype, res->ai_protocol);