mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/lib/socket.rb (family_addrinfo): return the given
addrinfo object. Patch by Ippei Obayashi. [ruby-dev:45095] [Bug #5845] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
98ddbafb26
commit
268d1a2244
3 changed files with 27 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
Mon Jan 9 20:08:52 2012 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/lib/socket.rb (family_addrinfo): return the given
|
||||
addrinfo object.
|
||||
Patch by Ippei Obayashi. [ruby-dev:45095] [Bug #5845]
|
||||
|
||||
Mon Jan 9 19:40:20 2012 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* test/zlib/test_zlib.rb (TestZlibGzipWriter#test_writer_wrap): set
|
||||
|
|
|
@ -16,6 +16,9 @@ class Addrinfo
|
|||
raise ArgumentError, "no address specified"
|
||||
elsif Addrinfo === args.first
|
||||
raise ArgumentError, "too many arguments" if args.length != 1
|
||||
addrinfo = args.first
|
||||
raise ArgumentError, "Addrinfo type mismatch" if (self.pfamily != addrinfo.pfamily) || (self.socktype != addrinfo.socktype) || (self.protocol != addrinfo.protocol)
|
||||
addrinfo
|
||||
elsif self.ip?
|
||||
raise ArgumentError, "IP address needs host and port but #{args.length} arguments given" if args.length != 2
|
||||
host, port = args
|
||||
|
|
|
@ -352,6 +352,24 @@ class TestSocketAddrinfo < Test::Unit::TestCase
|
|||
# not test failure
|
||||
end
|
||||
}
|
||||
|
||||
TCPServer.open("0.0.0.0", 0) {|serv|
|
||||
serv_ai = Addrinfo.new(serv.getsockname, :INET, :STREAM)
|
||||
serv_ai = tcp_unspecified_to_loopback(serv_ai)
|
||||
port = random_port
|
||||
begin
|
||||
serv_ai.connect_from(Addrinfo.tcp("0.0.0.0", port)) {|s1|
|
||||
s2 = serv.accept
|
||||
begin
|
||||
assert_equal(port, s2.remote_address.ip_port)
|
||||
ensure
|
||||
s2.close
|
||||
end
|
||||
}
|
||||
rescue *errors_addrinuse
|
||||
# not test failure
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def test_connect_to
|
||||
|
|
Loading…
Add table
Reference in a new issue