| 31 |
|
#include <stdarg.h> |
| 32 |
|
#include <errno.h> |
| 33 |
|
#include <netdb.h> |
| 34 |
+ |
#include <netinet/in.h> |
| 35 |
|
|
| 36 |
< |
#include "ukcprog.h" |
| 37 |
< |
#include "statgrab.h" |
| 36 |
> |
#include <ukcprog.h> |
| 37 |
> |
#include <statgrab.h> |
| 38 |
|
|
| 39 |
|
#define LOG_CRIT 0 |
| 40 |
|
#define LOG_ERR 1 |
| 224 |
|
|
| 225 |
|
if((get_host_addr(hostname, &haddr))!=0){ |
| 226 |
|
log_msg(LOG_CRIT, "Failed to lookup name for %s", hostname); |
| 227 |
+ |
close(sock); |
| 228 |
|
return NULL; |
| 229 |
|
} |
| 230 |
|
|
| 236 |
|
log_msg(LOG_DEBUG, "Creating a tcp connection"); |
| 237 |
|
if(connect(sock, (struct sockaddr *)&addr, sizeof(addr)) !=0){ |
| 238 |
|
log_msg(LOG_CRIT, "Failed to connect to hostname %s on port %d", hostname, port); |
| 239 |
+ |
close(sock); |
| 240 |
|
return NULL; |
| 241 |
|
} |
| 242 |
|
|