=item B<-l> I<address>
-Tells the daemon to bind to I<address> and accept incoming connections on that
+Tells the daemon to bind to I<address> and accept incoming TCP connections on that
socket. If I<address> begins with C<unix:>, everything following that prefix is
interpreted as the path to a UNIX domain socket. Otherwise the address or node
name are resolved using C<getaddrinfo()>.
C<B<[>I<address>B<]:>I<port>>. If the address is an IPv4 address or a fully
qualified domain name (i.E<nbsp>e. the address contains at least one dot
(C<.>)), the square brackets can be omitted, resulting in the (simpler)
-C<I<address>B<:>I<port>> pattern. The default port is B<42217/tcp>. If you
+C<I<address>B<:>I<port>> pattern. The default port is B<42217>. If you
specify a network socket, it is mandatory to read the
L</"SECURITY CONSIDERATIONS"> section.
[<hostname-or-ip>]:<port>
<hostname-or-ipv4>:<port>
-If the B<-l> option is not specified the default address,
+Given a port without a host (e.g. C<-l :42217>) the daemon will listen
+on that port on all network interfaces.
+
+If no B<-l> option is not specified the default address,
C<unix:/tmp/rrdcached.sock>, will be used.
+Multiple B<-l> options may be provided.
=item B<-s> I<group_name>|I<gid>
#include <signal.h>
#include <sys/un.h>
#include <netdb.h>
+#include <arpa/inet.h>
#include <poll.h>
#include <syslog.h>
#include <pthread.h>
char addr_copy[NI_MAXHOST];
char *addr;
char *port;
+ int addr_is_wildcard = 0;
int status;
strncpy (addr_copy, sock->addr, sizeof(addr_copy)-1);
port++;
}
}
+ /* Empty string for address should be treated as wildcard (open on
+ * all interfaces) */
+ addr_is_wildcard = (0 == *addr);
+ if (addr_is_wildcard)
+ ai_hints.ai_flags |= AI_PASSIVE;
+
ai_res = NULL;
- status = getaddrinfo (addr,
+ status = getaddrinfo (addr_is_wildcard ? NULL : addr,
port == NULL ? RRDCACHED_DEFAULT_PORT : port,
&ai_hints, &ai_res);
if (status != 0)
}
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+#ifdef IPV6_V6ONLY
+ /* Prevent EADDRINUSE bind errors on dual-stack configurations
+ * with IPv4-mapped-on-IPv6 enabled */
+ if (AF_INET6 == ai_ptr->ai_family)
+ setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one));
+#endif /* IPV6_V6ONLY */
status = bind (fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
if (status != 0)