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


Guile Reference Manual

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

38.11.2.4 The Service Database

The following functions accept an object representing a service and return a selected component:

Scheme Procedure: servent:name serv
The "official" name of the network service.
Scheme Procedure: servent:aliases serv
A list of aliases for the network service.
Scheme Procedure: servent:port serv
The Internet port used by the service.
Scheme 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 following procedures are used to search the service database:

Scheme Procedure: getserv [name [protocol]]
Scheme Procedure: getservbyname name protocol
Scheme Procedure: getservbyport port protocol
C Function: scm_getserv (name, 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).

 
(getserv "imap" "tcp")
=> #("imap2" ("imap") 143 "tcp")

(getservbyport 88 "udp")
=> #("kerberos" ("kerberos5" "krb5") 88 "udp")

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

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

Scheme Procedure: getservent
Return the next entry from the services database.

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

Scheme Procedure: setserv [stayopen]
C Function: scm_setserv (stayopen)
If stayopen is omitted, this is equivalent to endservent. Otherwise it is equivalent to setservent stayopen.


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

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