All Manuals > LispWorks® User Guide and Reference Manual > 32 The COMM Package

get-service-entry Function

Summary

Returns information about a service.

Package

comm

Signature

get-service-entry service protocol &key fields => value*

Arguments
service
An integer or a string.
protocol
A string or nil.
fields
A list of keywords specifying which information is required.
Values
value*
Multiple values corresponding to the keywords in fields, as described below.
Description

The function get-service-entry looks up service in the system database. If service is an integer, it is the port number to look up. If service is a string, it is a name to look up (it may be one of the aliases).

If protocol is a string, then get-service-entry looks for a system database entry with protocol protocol, otherwise it finds the first entry with any protocol.

fields specifies which information is returned. When get-service-entry finds an entry, it returns information about it as multiple values corresponding to the keywords in fields. These keywords can be:

:name
Return the name of the entry.
:port
Return the port number of the entry.
:aliases
Return a list of aliases of the service.
:protocol
Return the protocol of the entry, as lowercase strings like "tcp" or "udp".

If service is an integer then the default value of fields is (:name). Otherwise the default value of fields is (:port).

Notes
  1. get-service-entry tells you what the host computer knows. The results can be quite different between computers.
  2. There can be multiple entries with the same name but different protocols. Many services have entries for both UDP and TCP, normally with the same port number. In many cases the protocol that is selected when you pass protocol nil is not the correct protocol to use.
Examples
(get-service-entry "smtp" nil) => 25
(get-service-entry 25 nil :fields '(:name :aliases)) => "smtp", ("mail")
(get-service-entry "mail" nil) => 25
See also

25.3 Specifying the target for connecting and binding a socket
25 TCP and UDP socket communication and SSL


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:26