Commit a9593e1f authored by Tomoyuki Sahara's avatar Tomoyuki Sahara

v4/v6 fallback for TCP.

parent 76e1017f
...@@ -70,7 +70,6 @@ class Addrinfo ...@@ -70,7 +70,6 @@ class Addrinfo
else else
proto = '???' proto = '???'
end end
# how can we get the last part?
"#<Addrinfo: #{inspect_sockaddr} #{proto}>" "#<Addrinfo: #{inspect_sockaddr} #{proto}>"
else else
"#<Addrinfo: #{self.unix_path} SOCK_STREAM>" "#<Addrinfo: #{self.unix_path} SOCK_STREAM>"
...@@ -228,11 +227,19 @@ class TCPSocket ...@@ -228,11 +227,19 @@ class TCPSocket
if self.is_a? TCPServer if self.is_a? TCPServer
super(host, service) super(host, service)
else else
ai = Addrinfo.getaddrinfo(host, service)[0] s = nil
super(Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0), "r+") e = SocketError
# XXX: bind(2) Addrinfo.foreach(host, service) { |ai|
Socket._connect(self.fileno, ai.to_sockaddr) begin
self s = Socket._socket(ai.afamily, Socket::SOCK_STREAM, 0)
Socket._connect(s, ai.to_sockaddr)
super(s, "r+")
return
rescue => e0
e = e0
end
}
raise e
end end
end end
......
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