[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Reverse of Socket::getservbyname?

Aquila

12/19/2004 4:18:00 PM

Is there a way to resolve ports by using some method of Socket?
I could parse /etc/services but I'd rather like to use existing methods...
--
"May the source be with you"
1 Answer

mfuhr

12/20/2004 4:06:00 AM

0

Aquila <braempje@netscape.net> writes:

> Is there a way to resolve ports by using some method of Socket?
> I could parse /etc/services but I'd rather like to use existing methods...

The C function is getservbyport() but I don't see it implemented
in Socket, at least not in Ruby 1.8.2. Socket.getnameinfo appears
to work:

irb(main):002:0> Socket.getnameinfo([nil, 80, nil])
=> ["localhost", "http"]

--
Michael Fuhr
http://www.fuhr.o...