summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-11-18 10:31:53 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-11-18 10:31:53 +0100
commit44aad3ddd3dd8638b7623b53cbca9f59d886ba1d (patch)
tree90f7fdf29fc9def1cb92e88b1431e3cd905855f8 /contrib
parente1e5d64c157320948c8f4283e584564b26a5c3e5 (diff)
downloadODR-AudioEnc-44aad3ddd3dd8638b7623b53cbca9f59d886ba1d.tar.gz
ODR-AudioEnc-44aad3ddd3dd8638b7623b53cbca9f59d886ba1d.tar.bz2
ODR-AudioEnc-44aad3ddd3dd8638b7623b53cbca9f59d886ba1d.zip
Common 0a50ea0: Set SO_REUSEADDR for TCP sockets
Diffstat (limited to 'contrib')
-rw-r--r--contrib/Socket.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/contrib/Socket.cpp b/contrib/Socket.cpp
index 0c3cbb4..cba2767 100644
--- a/contrib/Socket.cpp
+++ b/contrib/Socket.cpp
@@ -490,6 +490,11 @@ void TCPSocket::listen(int port, const string& name)
continue;
}
+ int reuse_setting = 1;
+ if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &reuse_setting, sizeof(reuse_setting)) == -1) {
+ throw runtime_error("Can't reuse address");
+ }
+
if (::bind(sfd, rp->ai_addr, rp->ai_addrlen) == 0) {
m_sock = sfd;
break;