Go to the first, previous, next, last section, table of contents.


Networking Databases

This section describes procedures which convert internet addresses and query various network databases. Care should be taken when using the database routines since they are not reentrant.

primitive: inet-aton address
Converts a string containing an Internet host address in the traditional dotted decimal notation into an integer.

(inet-aton "127.0.0.1") => 2130706433

primitive: inet-ntoa number
Converts an integer Internet host address into a string with the traditional dotted decimal representation.

(inet-ntoa 2130706433) => "127.0.0.1"

primitive: inet-netof address
Returns the network number part of the given integer Internet address.

(inet-netof 2130706433) => 127

primitive: inet-lnaof address
Returns the local-address-with-network part of the given Internet address.

(inet-lnaof 2130706433) => 1

primitive: inet-makeaddr net lna
Makes an Internet host address by combining the network number net with the local-address-within-network number lna.

(inet-makeaddr 127 1) => 2130706433

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 hostent functions accept a host object and return some information about that host's presence on the network.

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

The gethost functions are used to find a particular host's entry in the host database.

primitive: gethost [host]
procedure: gethostbyname hostname
procedure: gethostbyaddr address
Look up a host by name or address, and return 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).

The following three procedures may be used to step through the host database from beginning to end. [FIXME: document the `sethost' variant of `sethostent'.]

procedure: sethostent
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.

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.

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

The netent functions accept an object representing a network and return a selected component.

procedure: netent:name net
The "official" network name.
procedure: netent:aliases net
A list of aliases for the network.
procedure: netent:addrtype net
The type of the network number. Currently, this returns only AF_INET.
procedure: netent:net net
The network number.

The getnet procedures look up a particular network in the network database. Each returns a network object that describes the network's technical nature.

primitive: getnet [net]
procedure: getnetbyname net-name
procedure: getnetbyaddr net-number
Look up a network by name or net number in the network database. The net-name argument must be a string, and the net-number argument must be an integer. getnet will accept either type of argument, behaving like getnetent (see below) if no arguments are given.

[FIXME: document the `setnet' variant of `setnetent'.]

procedure: setnetent
Initializes a stream used by getnetent to read from the network database. The next use of getnetent will return the first entry. The return value is unspecified.

procedure: getnetent
Return the next entry from the network database.

procedure: endnetent
Close the stream used by getnetent. The return value is unspecified.

The protoent procedures accept an object representing a protocol and return a selected component.

procedure: protoent:name protocol
The "official" protocol name.
procedure: protoent:aliases protocol
A list of aliases for the protocol.
procedure: protoent:proto protocol
The protocol number.

The getproto procedures look up a particular network protocol and return a protocol object.

primitive: getproto [protocol]
procedure: getprotobyname name
procedure: getprotobynumber number
Look up a network protocol by name or by number. getprotobyname takes a string argument, and getprotobynumber takes an integer argument. getproto will accept either type, behaving like getprotoent (see below) if no arguments are supplied.

[FIXME: document the `setproto' variant of `setprotoent'.]

procedure: setprotoent
Initializes a stream used by getprotoent to read from the protocol database. The next use of getprotoent will return the first entry. The return value is unspecified.

procedure: getprotoent
Return the next entry from the protocol database.

procedure: endprotoent
Close the stream used by getprotoent. The return value is unspecified.

The servent procedures accept a service object and return some information about that service.

procedure: servent:name serv
The "official" name of the network service.
procedure: servent:aliases serv
A list of aliases for the network service.
procedure: servent:port serv
The Internet port used by the service.
procedure: servent:proto serv
The protocol used by the service. A service may be listed many times in the database under different protocol names.

The getserv procedures look up a network service and return a service object which describes the names and network ports conventionally assigned to the service.

primitive: getserv [name protocol]
procedure: getservbyname name protocol
procedure: getservbyport port protocol
Look up a network service by name or by service number, and return a network service object. The protocol argument specifies the name of the desired protocol; if the protocol found in the network service database does not match this name, a system error is signalled.

The getserv procedure will take either a service name or number as its first argument; if given no arguments, it behaves like getservent (see below).

[FIXME: document the `setserv' variant of `setservent'.]

procedure: setservent
Initializes a stream used by getservent to read from the services database. The next use of getservent will return the first entry. The return value is unspecified.

procedure: getservent
Return the next entry from the services database.

procedure: endservent
Close the stream used by getservent. The return value is unspecified.


Go to the first, previous, next, last section, table of contents.