From 640595f37fb58cdfe96731a5d993344bcdabcad0 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 12 Sep 2017 16:43:25 +0200 Subject: Reuse socket address for DPD server --- src/OutputUHDFeedback.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/OutputUHDFeedback.cpp b/src/OutputUHDFeedback.cpp index a8f2c2e..22fa7eb 100644 --- a/src/OutputUHDFeedback.cpp +++ b/src/OutputUHDFeedback.cpp @@ -230,6 +230,12 @@ void OutputUHDFeedback::ServeFeedback() addr.sin_port = htons(m_port); addr.sin_addr.s_addr = htonl(INADDR_ANY); + const int reuse = 1; + if (setsockopt(m_server_sock, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) + < 0) { + throw std::runtime_error("Can't reuse address for TCP socket"); + } + if (bind(m_server_sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) { close(m_server_sock); throw std::runtime_error("Can't bind TCP socket"); -- cgit v1.2.3