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

9.11.4 Netdb interface

Builtin Class: <sys-hostent>
A class of objects for network hosts. Corresponding to struct hostent. The following slots are available read-only.

Instance Variable: <sys-hostent> name
The formal name of the host (string).
Instance Variable: <sys-hostent> aliases
A list of alias names of the host (list of strings).
Instance Variable: <sys-hostent> addresses
A list of addresses (list of strings). Only ipv4 address is supported currently. Each address is represented by dotted decimal notation.

Function: sys-gethostbyname name
Looks up a host named name. If found, returns a <sys-hostent> object. Otherwise, returns #f.
 
(let ((host (sys-gethostbyname "www.w3c.org")))
  (list (slot-ref host 'name)
        (slot-ref host 'aliases)
        (slot-ref host 'addresses)))
  => ("www.w3.org" ("www.w3c.org") ("18.29.1.34" "18.29.1.35"))

Function: sys-gethostbyaddr addr proto
Looks up a host that has an address addr of protocol proto. addr is a natural string representation of the address; for ipv4, it is a dotted decimal notation. proto is a protocol number; only AF_INET is supported currently. If the host is found, returns a <sys-hostent> object. Otherwise, returns #f.
 
(let ((host (sys-gethostbyaddr "127.0.0.1" AF_INET)))
  (list (slot-ref host 'name)
        (slot-ref host 'aliases)
        (slot-ref host 'addresses))
  => ("localhost" ("localhost.localdomain") ("127.0.0.1"))

Builtin Class: <sys-servent>
An entry of the network service database. Corresponding to struct servent. The following slots are available read-only.

Instance Variable: <sys-servent> name
The formal name of the service (string).
Instance Variable: <sys-servent> aliases
A list of alias names of the service (list of strings).
Instance Variable: <sys-servent> port
A port number registered for this service (exact integer).
Instance Variable: <sys-servent> proto
A protocol name for this service (string).

Function: sys-getservbyname name proto
Looks up the network service database with a service name name and a protocol proto. Both name and proto must be a string. If a service is found, an instance of <sys-servent> is returned. Otherwise, #f is returned.
 
(let ((serv (sys-getservbyname "http" "tcp")))
  (list (slot-ref serv 'name)
        (slot-ref serv 'aliases)
        (slot-ref serv 'port)
        (slot-ref serv 'proto)))
  => ("http" () 80 "tcp")

Function: sys-getservbyport port proto
Looks up the network service database with a service port port and a protocol proto. port must be an exact integer, and proto must be a string. If a service is found, an instance of <sys-servent> is returned. Otherwise, #f is returned.
 
(let ((serv (sys-getservbyport 6000 "tcp")))
  (list (slot-ref serv 'name)
        (slot-ref serv 'aliases)
        (slot-ref serv 'port)
        (slot-ref serv 'proto)))
  => ("x-server" () 6000 "tcp")

Builtin Class: <sys-protoent>
An entry of the protocol database. Corresponds to struct protoent in C. The following slots are available read-only.

Instance Variable: <sys-servent> name
The formal name of the protocol (string).
Instance Variable: <sys-servent> aliases
A list of alias names of the protocol (list of strings).
Instance Variable: <sys-servent> proto
A protocol number (exact integer).

Function: sys-getprotobyname name
Looks up the network protocol database with a name name, which must be a string. If a protocol is found, an instance of <sys-protoent> is returned. Otherwise, #f is returned.
 
(let ((proto (sys-getprotobyname "icmp")))
  (list (slot-ref proto 'name)
        (slot-ref proto 'aliases)
        (slot-ref proto 'proto)))
  => ("icmp" ("ICMP") 1)

Function: sys-getprotobynumber number
Looks up the network protoice database with a protocol number number, which must be an exact integer. If a protocol is found, an instance of <sys-protoent> is returned. Otherwise, #f is returned.
 
(let ((proto (sys-getprotobynumber 17)))
  (list (slot-ref proto 'name)
        (slot-ref proto 'aliases)
        (slot-ref proto 'proto)))
  => ("udp" ("UDP") 17)


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

This document was generated by Ken Dickey on November, 28 2002 using texi2html