Project

General

Profile

Feature #3953

TCPSocket / UDPSocket do not accept IPAddr objects.

Added by Hal Brodigan almost 6 years ago. Updated over 3 years ago.

Status:
Assigned
Priority:
Normal
Assignee:
[ruby-core:32824]

Description

=begin
I noticed that TCPSocket/UDPSocket only accept String IPs/Hostnames, but not IPAddr objects. This is counter-intuitive since IP Addresses, along with Hostnames, are used to connect/bind to sockets.

 require 'socket'
 require 'resolv'

 ip = IPAddr.new(Resolv.getaddress('www.example.com'))
 sock = TCPSocket.new(ip,80)
 TypeError: can't convert IPAddr into String
from (irb):5:in `initialize'
from (irb):5:in `new'
from (irb):5

=end

History

#1 [ruby-core:43425] Updated by Akira Tanaka over 4 years ago

  • Description updated (diff)

If we implement this feature, we need a method for duck type, such as IPAddr#to_ipaddress to convert to IP-address string.

#2 [ruby-core:43426] Updated by Hiroshi Nakamura over 4 years ago

  • Category set to ext
  • Assignee set to Akinori MUSHA

knu, how do you think?

#3 Updated by Shyouhei Urabe over 4 years ago

  • Status changed from Open to Assigned

#4 [ruby-core:49701] Updated by Yusuke Endoh over 3 years ago

  • Target version set to next minor

Also available in: Atom PDF