Commit 2a80cccf authored by rhykw's avatar rhykw

TCPServer use SO_REUSEADDR

parent 18f7b45a
...@@ -262,6 +262,7 @@ class TCPServer ...@@ -262,6 +262,7 @@ class TCPServer
ai = Addrinfo.getaddrinfo(host, service, nil, nil, nil, Socket::AI_PASSIVE)[0] ai = Addrinfo.getaddrinfo(host, service, nil, nil, nil, Socket::AI_PASSIVE)[0]
@init_with_fd = true @init_with_fd = true
super(Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0), "r+") super(Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0), "r+")
self.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
Socket._bind(self.fileno, ai.to_sockaddr) Socket._bind(self.fileno, ai.to_sockaddr)
listen(5) listen(5)
self 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