Maintenance of Ruby 2.0.0 ended on February 24, 2016. Read more

In Files

  • ipaddr.rb


Public Class Methods

getaddress(s) click to toggle source

Returns a String based representation of a valid DNS hostname, IPv4 or IPv6 address.

IPSocket.getaddress 'localhost'         #=> "::1"
IPSocket.getaddress 'broadcasthost'     #=> ""
IPSocket.getaddress '' #=> ""
IPSocket.getaddress ''        #=> "2a00:1328:e102:ccc0::122"
               # File ipaddr.rb, line 650
def getaddress(s)
  if valid_v6?(s)
Also aliased as: getaddress_orig
getaddress_orig(s) click to toggle source
Alias for: getaddress

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit