use SO_REUSEADDR in accept loop

master
Christian Ulrich 2020-10-24 19:00:49 +02:00
parent a986bd52b8
commit b0398adc12
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
2 changed files with 2 additions and 1 deletions

View File

@ -239,7 +239,7 @@ proc runApp(serverHostname: string, serverPort: Port, peerId: string,
srcPort)
asyncCheck handleServerMessages(serverConn)
let sock = await punchHole(punchdConn, serverConn, peerId, otherPeerId,
"tcp-nutss")
"tcp-syni")
echo "connected!"
await sock.send("ping")
let msg = await sock.recv(4)

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: