net-service port not service?

Q&A's, tips, howto's
Locked
kanen
Posts: 145
Joined: Thu Mar 25, 2010 6:24 pm
Contact:

net-service port not service?

Post by kanen »

I like net-service:

Code: Select all

net-service
syntax: (net-service str-service str-protocol)
Makes a lookup in the services database and returns the standard port number for this service.
Returns nil on failure.
 (net-service "ftp" "tcp") --> 21
But, I would like to be able to specify a port, not a service name, and get the name back. Right now, I have code that parses the "services" file and does this.

Code: Select all

(net-service "" "tcp" 21)  --> ftp
syntax: (net-service str-service str-protocol port-number)
Returns nil on failure or the name of the service.
Thoughts?
. Kanen Flowers http://kanen.me .

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: net-service port not service?

Post by Lutz »

that was easy to add:

Code: Select all

newLISP v.10.2.2 on Win32 IPv4, execute 'newlisp -h' for more info.

> (net-service 22 "tcp")
"ssh"
> (net-service "ssh" "tcp")
22
>
I will post a development version 10.2.2 when back from Europe on the 22nd/23rd of of April.

Locked