Page 1 of 1

net-service port not service?

Posted: Fri Apr 02, 2010 11:23 pm
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?

Re: net-service port not service?

Posted: Sat Apr 03, 2010 8:14 am
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.