Project

General

Profile

Actions

Feature #3953

open

TCPSocket / UDPSocket do not accept IPAddr objects.

Added by postmodern (Hal Brodigan) about 14 years ago. Updated almost 7 years ago.

Status:
Assigned
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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0