Actions
Bug #5845
closedAddrinfo#connect_from が Addrinfo オブジェクトを受け付けない
Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-01-04 trunk 34210) [x86_64-linux]
Backport:
Description
Addrinfo#connect_from (ext/socket/lib/socket.rb) の rdoc には
# Addrinfo object can be taken for the argument.¶
Addrinfo.tcp("www.ruby-lang.org", 80).connect_from(Addrinfo.tcp("0.0.0.0", 4649)) {|s|¶
s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"¶
puts s.read¶
}¶
とあり、 Addrinfo オブジェクトを受け付けるように書かれていますが、実際には
その内容は無視されてしまいます。以下のようなスクリプトで確認できます。
require 'socket'
Addrinfo.tcp("www.example.com", 80).connect_from(Addrinfo.tcp("0.0.0.0", 49021)) {|s|
p s.local_address.ip_port
s.close
}
原因は Addrinfo#family_addrinfo に Addrinfo オブジェクトを渡した時の返り値が適切でないことです。
添付したパッチでとりあえずは期待通りに動きます。
適当に作った問題再現用テストも添付します。
Files
Updated by akr (Akira Tanaka) over 11 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r34244.
Ippei, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- ext/socket/lib/socket.rb (family_addrinfo): return the given
addrinfo object.
Patch by Ippei Obayashi. [ruby-dev:45095] [Bug #5845]
Actions
Like0
Like0