Commit 4f670320 authored by rhykw's avatar rhykw

TCPServer use SO_REUSEADDR if possible

parent 2a80cccf
......@@ -262,7 +262,9 @@ class TCPServer
ai = Addrinfo.getaddrinfo(host, service, nil, nil, nil, Socket::AI_PASSIVE)[0]
@init_with_fd = true
super(Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0), "r+")
if Socket.const_defined?(:SO_REUSEADDR)
self.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
end
Socket._bind(self.fileno, ai.to_sockaddr)
listen(5)
self
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment