Project

General

Profile

Feature #3953

TCPSocket / UDPSocket do not accept IPAddr objects.

Added by postmodern (Hal Brodigan) over 8 years ago. Updated about 1 year ago.

Status:
Assigned
Priority:
Normal
Target version:
-
[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

Updated by akr (Akira Tanaka) almost 7 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.

Updated by nahi (Hiroshi Nakamura) almost 7 years ago

  • Category set to ext
  • Assignee set to knu (Akinori MUSHA)

knu, how do you think?

#3

Updated by shyouhei (Shyouhei Urabe) almost 7 years ago

  • Status changed from Open to Assigned

Updated by mame (Yusuke Endoh) about 6 years ago

  • Target version set to 2.6
#5

Updated by naruse (Yui NARUSE) about 1 year ago

  • Target version deleted (2.6)

Also available in: Atom PDF