www.delorie.com/gnu/docs/guile/guile_427.html   search  
Buy GNU books!

Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] The Host Database

A host object is a structure that represents what is known about a network host, and is the usual way of representing a system's network identity inside software.

The following functions accept a host object and return a selected component:

Scheme Procedure: hostent:name host
The "official" hostname for host.
Scheme Procedure: hostent:aliases host
A list of aliases for host.
Scheme Procedure: hostent:addrtype host
The host address type. For hosts with Internet addresses, this will return AF_INET.
Scheme Procedure: hostent:length host
The length of each address for host, in bytes.
Scheme Procedure: hostent:addr-list host
The list of network addresses associated with host.

The following procedures are used to search the host database:

Scheme Procedure: gethost [host]
Scheme Procedure: gethostbyname hostname
Scheme Procedure: gethostbyaddr address
C Function: scm_gethost (host)
Look up a host by name or address, returning a host object. The gethost procedure will accept either a string name or an integer address; if given no arguments, it behaves like gethostent (see below). If a name or address is supplied but the address can not be found, an error will be thrown to one of the keys: host-not-found, try-again, no-recovery or no-data, corresponding to the equivalent h_error values. Unusual conditions may result in errors thrown to the system-error or misc_error keys.

(gethost "www.gnu.org")
=> #("www.gnu.org" () 2 4 (3353880842))

(gethostbyname "www.emacs.org")
=> #("emacs.org" ("www.emacs.org") 2 4 (1073448978))

The following procedures may be used to step through the host database from beginning to end.

Scheme Procedure: sethostent [stayopen]
Initialize an internal stream from which host objects may be read. This procedure must be called before any calls to gethostent, and may also be called afterward to reset the host entry stream. If stayopen is supplied and is not #f, the database is not closed by subsequent gethostbyname or gethostbyaddr calls, possibly giving an efficiency gain.

Scheme Procedure: gethostent
Return the next host object from the host database, or #f if there are no more hosts to be found (or an error has been encountered). This procedure may not be used before sethostent has been called.

Scheme Procedure: endhostent
Close the stream used by gethostent. The return value is unspecified.

Scheme Procedure: sethost [stayopen]
C Function: scm_sethost (stayopen)
If stayopen is omitted, this is equivalent to endhostent. Otherwise it is equivalent to sethostent stayopen.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003