Class Sys::Host
In: ext/bsd/sys/host.c
Parent: Object

The Host class encapsulates information about your machine, such as

   the host name and IP address.

Methods

host_id   hostname   info   ip_addr  

Classes and Modules

Class Sys::Host::Error

Constants

VERSION = 0.6.2   The version of this library. This is a string, not a number.

Public Class methods

Sys::Host.host_id

Returns the host id of the current machine.

Returns the hostname of the current host. This may or not return the FQDN, depending on your system.

: Yields a HostInfo struct containing various bits of information about the local machine for each entry in the hosts table. In non-block form, returns an array of HostInfo structs.

The Struct::HostInfo struct contains 5 fields:

  • name (String)
  • aliases (Array)
  • addr_type (Integer) => Typically 2 (AF_INET) or 28 (AF_INET6)
  • length (Integer) => Typically 4 (IPv4) or 16 (IPv6)
  • addr_list (Array)

Returns a list of IP addresses for the current host (yes, it is possible to have more than one).

[Validate]