diff --git a/plugins/netutils.c b/plugins/netutils.c
index 1fa69a358f86101d063a494f685102dbeb4e9955..6702b13f25250439416549681e85f5aa98a8d316 100644 (file)
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
+* $Id$
+*
****************************************************************************/
#include "common.h"
send_result = send (sd, send_buffer, strlen (send_buffer), 0);
if (send_result<0 || (size_t)send_result!=strlen(send_buffer)) {
- printf ("send() failed\n");
+ printf ("Send failed\n");
result = STATE_WARNING;
}
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)
@@ -304,7 +307,7 @@ send_udp_request (int sd, const char *send_buffer, char *recv_buffer, int recv_s
int
send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int recv_size)
{
- int result;
+ int result = STATE_OK;
int send_result;
int recv_result;
struct timeval tv;
@@ -312,7 +315,7 @@ send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int
send_result = send (sd, send_buffer, strlen (send_buffer), 0);
if (send_result<0 || (size_t)send_result!=strlen(send_buffer)) {
- printf ("send() failed\n");
+ printf ("Send failed\n");
result = STATE_WARNING;
}
@@ -336,7 +339,7 @@ send_request (int sd, int proto, const char *send_buffer, char *recv_buffer, int
if (recv_result == -1) {
strcpy (recv_buffer, "");
if (proto != IPPROTO_TCP)
- printf ("recv() failed\n");
+ printf ("Receive failed\n");
result = STATE_WARNING;
}
else