diff options
Diffstat (limited to 'contrib/Socket.cpp')
-rw-r--r-- | contrib/Socket.cpp | 5 |
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; |