summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f220617)
raw | patch | inline | side by side (parent: f220617)
author | Pavel Shramov <sharmov@mexmat.net> | |
Thu, 29 Nov 2007 10:37:22 +0000 (13:37 +0300) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Thu, 29 Nov 2007 10:56:01 +0000 (11:56 +0100) |
This patch allows other programs to bind same port and process data from clients
not interfering with master collectd server.
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
not interfering with master collectd server.
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/network.c | patch | blob | history |
diff --git a/src/network.c b/src/network.c
index 21b969406907787230f173b2f2faeba5a3b6e20a..ab04f4c13bd349117b1f3dd324b638ef2e4edb1a 100644 (file)
--- a/src/network.c
+++ b/src/network.c
@@ -683,6 +683,15 @@ static int network_bind_socket (const sockent_t *se, const struct addrinfo *ai)
{
int loop = 0;
+ /* allow multiple sockets to use the same PORT number */
+ if (setsockopt(se->fd, SOL_SOCKET, SO_REUSEADDR,
+ &loop, sizeof(loop)) == -1) {
+ char errbuf[1024];
+ ERROR ("setsockopt: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (-1);
+ }
+
DEBUG ("fd = %i; calling `bind'", se->fd);
if (bind (se->fd, ai->ai_addr, ai->ai_addrlen) == -1)