Next: , Previous: , Up: posix socket   [Index]


4.15.4 Network services database

Structure Type: struct-servent

Scheme level representation of struct servent. It has the following fields:

s_name

Bytevector, the ASCII coding of the official service name.

s_aliases

Null or list of bytevectors, the ASCII codings of service name aliases.

s_port

Fixnum, the port number.

s_proto

Bytevector, ASCII coding of the associated protocol name.

Function: make-struct-servent name aliases port proto

Build and return an instance of struct-servent.

Function: struct-servent-s_name servent
Function: struct-servent-s_aliases servent
Function: struct-servent-s_proto servent
Function: struct-servent-s_port servent

Accessors for the fields of struct-servent.

Function: getservbyname name protocol

Interface to the C function getservbyname(), (libc)getservbyname. Given the strings or bytevectors name and protocol holding the ASCII coding of a network service name and protocol, query the network services database and build an instance of struct-servent mirroring the resulting struct servent entry. If successful return the data structure, else raise an exception.

(px.getservbyname "smtp" "tcp")
⇒ #["struct-servent"
        s_name="smtp"
        s_aliases=(mail)
        s_port=25
        s_proto=tcp]

(px.getservbyname "ntp" "udp")
⇒ #["struct-servent"
        s_name="ntp"
        s_aliases=()
        s_port=123
        s_proto=udp]
Function: getservbynumber port protocol

Interface to the C function getservbynumber(), (libc)getservbynumber. Given a fixnum port and a string or bytevector protocol being the port number and protocol name of a network service, query the network services database and build an instance of struct-servent mirroring the resulting struct servent entry. If successful return the data structure, else raise an exception.

(px.getservbyport 80 "tcp")
⇒ #["struct-servent"
        s_name="http"
        s_aliases=(www-http www)
        s_port=80
        s_proto=tcp]
Function: service-entries

Interface to the C functions setservent(), getservent() and endservent(), (libc)setservent. Scan the network service database and build a list of struct-servent mirroring the resulting struct servent entries. Return the list of structures.


Next: , Previous: , Up: posix socket   [Index]