summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 68ecdb7)
raw | patch | inline | side by side (parent: 68ecdb7)
author | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | |
Wed, 1 Dec 2004 08:28:36 +0000 (08:28 +0000) | ||
committer | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | |
Wed, 1 Dec 2004 08:28:36 +0000 (08:28 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@960 f882894a-f735-0410-b71e-b25c423dba1c
plugins/netutils.c | patch | blob | history |
diff --git a/plugins/netutils.c b/plugins/netutils.c
index c99983f03bd9e68a2cbeb348efce2d0b0a1ed1e3..aee53d35e70b2aca97f924e707d2eb2a3b07c6d0 100644 (file)
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
my_connect (const char *host_name, int port, int *sd, int proto)
{
struct addrinfo hints;
- struct addrinfo *res;
+ struct addrinfo *res, *res0;
char port_str[6];
int result;
hints.ai_socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
snprintf (port_str, sizeof (port_str), "%d", port);
- result = getaddrinfo (host_name, port_str, &hints, &res);
+ result = getaddrinfo (host_name, port_str, &hints, &res0);
if (result != 0) {
printf ("%s\n", gai_strerror (result));
return STATE_UNKNOWN;
}
else {
+ res = res0;
while (res) {
/* attempt to create a socket */
*sd = socket (res->ai_family, (proto == IPPROTO_UDP) ?
close (*sd);
res = res->ai_next;
}
- freeaddrinfo (res);
+ freeaddrinfo (res0);
}
if (result == 0)