use SO_REUSEADDR in accept loop

master
Christian Ulrich 2020-10-24 19:05:16 +02:00
parent 1b315f0eee
commit ca88330b4d
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 1 additions and 0 deletions

View File

@ -48,6 +48,7 @@ proc acceptConnections(punchd: Punchd, ip: IpAddress, port: Port,
else:
assert(false, "can only accept TCP or UDP connections")
let sock = newAsyncSocket(sockType = sockType, protocol = protocol)
sock.setSockOpt(OptReuseAddr, true)
sock.bindAddr(port, $ip)
sock.listen()
while true: