Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

GLib::InetAddress

class GLib::InetAddress

GLib::InetAddress represents an IPv4 or IPv6 internet address. Use GLib::Resolver#lookup_by_name or GLib::Resolver#lookup_by_name_async to look up the GLib::InetAddress for a hostname. Use GLib::Resolver#lookup_by_address or GLib::Resolver#lookup_by_address_async to look up the hostname for a GLib::InetAddress.

To actually connect to a remote host, you will need a GLib::InetSocketAddress (which includes a GLib::InetAddress as well as a port number).

Class Methods

GLib::InetAddress.new_any(family)
Creates a GLib::InetAddress for the “any” address (unassigned/“don’t care”) for family.
GLib::InetAddress.new_from_bytes(bytes, family)
Creates a new GLib::InetAddress from the given family and bytes. bytes should be 4 bytes for GLib::Socket::FAMILY_IPV4 and 16 bytes for GLib::Socket::FAMILY_IPV6.
GLib::InetAddress.new_from_string(string)
Parses string as an IP address and creates a new GLib::InetAddress.
  • string: A String representation of an IP address
  • Returns: a new GLib::InetAddress corresponding to string, or nil if string couldn’t be parsed
GLib::InetAddress.new_loopback(family)
Creates a GLib::InetAddress for the loopback address for family

Instance Methods

any?
Checks whether or not this is the “any” address for its family.
  • Returns: true if this is the “any” address for its family
bytes
Gets the raw address data.
  • Returns: The raw address data
family
Gets the address family (IPv4 or IPv6).
get_native_size

Gets the size of the native raw binary address for this address. This is the size of the data that you get from GLib::InetAddress#to_bytes.

Since 2.22

  • Returns: The number of bytes used for the native version of this address
link_local?
Checks whether or not this is a link-local address.
  • Returns: true if this is a link-local address
loopback?
Checks whether or not this is the loopback address for its family.
  • Returns: true if this is the loopback address for its family
mc_global?
Checks whether or not this is a global multicast address.
  • Returns: true if this is a global multicast address
mc_link_local?
Checks whether or not this is a link-local multicast address.
  • Returns: true if this is a link-local multicast address
mc_node_local?
Checks whether or not this is a node-local multicast address.
  • Returns: true if this is a node-local multicast address
mc_org_local?
Checks whether or not this is an organization-local multicast address.
  • Returns: true if this is an organization-local multicast address
mc_site_local?
Checks whether or not this is a site-local multicast address.
  • Returns: true if this is a site-local multicast address
multicast?
Checks whether or not this is a multicast address.
  • Returns: true if this is a multicast address
site_local?
Checks whether or not this is a site-local address.
  • Returns: true if this is a site-local address
to_bytes

Gets the raw binary address data from this address.

Since 2.22

  • Returns: A String containing the bytes in this address
to_s
Same as GLib::InetAddress#to_string.
to_str
Same as GLib::InetAddress#to_string.
to_string

Converts this address to String form.

Since 2.22

  • Returns: A representation of this address as a String

Properties

bytes: String (Read/Write)
The raw address data
family: GLib::SocketFamily (Read/Write)
The address family (IPv4 or IPv6)
is-any: true or false (Read)
Whether or not this is the "any" address for its family
is-link-local: true or false (Read)
Whether or not this is a link-local address
is-loopback: true or false (Read)
Whether or not this is the loopback address for its family
is-mc-global: true or false (Read)
Whether or not this is a global multicast address
is-mc-link-local: true or false (Read)
Whether or not this is a link-local multicast address
is-mc-node-local: true or false (Read)
Whether or not this is a node-local multicast address
is-mc-org-local: true or false (Read)
Whether or not this is an organization-local multicast address
is-mc-site-local: true or false (Read)
Whether or not this is a site-local multicast address
is-multicast: true or false (Read)
Whether or not this is a multicast address
is-site-local: true or false (Read)
Whether or not this is a site-local address
Last modified:2010/12/27 21:59:23
Keyword(s):
References:[index-ruby-gio2] [GLib::Resolver] [GLib::InetSocketAddress] [GLib::InetAddress] [index-ruby-glib2] [Ruby/GIO]