Closed kolbma closed 9 months ago
You need to call set_reuse_address
on all sockets before bind
ing on the address.
Please read the documentation on SO_REUSEPORT
in the socket(7)
manual.
@Thomasdezeeuw Ooch, tomatoes..., don't know why I didn't see that set_reuse_address
was for the wrong socket, had it before after binding, but like that it has been complete useless :-( Thanks, using a Result now, instead of dummy socket assign.
Hello,
could it be that you miss some kind of free/close the socket-binding, so that we have to wait for Linux to cleanup after some timeout?
If I use socket2 the 1st time it works and after process exit and checking there is no process and no listener at the tcp port anylonger, nevertheless in the next run I get
Error: BoxSend(Os { code: 98, kind: AddrInUse, message: "Address already in use" })
Looks like I have to wait 60 seconds each time between stopping and restarting my daemon process when using socket2 sockets.
Are you checking available TIME-WAIT states instead/in addition of LISTEN?
std::net
doesn't have this problem.My code looks like this and
addresses
is an array with a single address 127.0.0.1:9090.