X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fnetwork.c;h=a659189f3e7960d312d0d608f9f8af55d1e3c5bb;hb=acbd25344a59c091b087311804d375b759077e32;hp=21b969406907787230f173b2f2faeba5a3b6e20a;hpb=58ecdb7ff9a4d90e87daecca05b9cb4a43070fd7;p=collectd.git diff --git a/src/network.c b/src/network.c index 21b96940..a659189f 100644 --- a/src/network.c +++ b/src/network.c @@ -682,6 +682,16 @@ static int network_set_ttl (const sockent_t *se, const struct addrinfo *ai) static int network_bind_socket (const sockent_t *se, const struct addrinfo *ai) { int loop = 0; + int yes = 1; + + /* allow multiple sockets to use the same PORT number */ + if (setsockopt(se->fd, SOL_SOCKET, SO_REUSEADDR, + &yes, sizeof(yes)) == -1) { + char errbuf[1024]; + ERROR ("setsockopt: %s", + sstrerror (errno, errbuf, sizeof (errbuf))); + return (-1); + } DEBUG ("fd = %i; calling `bind'", se->fd);