#include <sys/types.h>
#include <sys/socket.h>
-
+#include <netinet/tcp.h>
#include <netdb.h>
#include "uhttpd.h"
if ((status = getaddrinfo(host, port, &hints, &addrs)) != 0) {
fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(status));
- return -1;
+ return 0;
}
/* try to bind a new socket to each found address */
tcp_ka_idl = 1;
tcp_ka_cnt = 3;
- tcp_ka_int = conf->tcp_keepalive;
+ tcp_ka_int = conf.tcp_keepalive;
ret = setsockopt(sock, SOL_TCP, TCP_KEEPIDLE, &tcp_ka_idl, sizeof(tcp_ka_idl)) ||
setsockopt(sock, SOL_TCP, TCP_KEEPINTVL, &tcp_ka_int, sizeof(tcp_ka_int)) ||
setsockopt(sock, SOL_TCP, TCP_KEEPCNT, &tcp_ka_cnt, sizeof(tcp_ka_cnt));
l->fd.fd = sock;
l->tls = tls;
list_add_tail(&l->list, &listeners);
+ bound++;
continue;
error:
- if (sock > 0)
+ if (sock > -1)
close(sock);
}