TCPServer use SO_REUSEADDR

This commit is contained in:
rhykw
2016-05-23 21:44:34 +09:00
parent 18f7b45ad1
commit 2a80cccf30
+1
View File
@@ -262,6 +262,7 @@ 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+")
self.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, true)
Socket._bind(self.fileno, ai.to_sockaddr)
listen(5)
self