[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

why is gethostbyname in TCPSocket?

msoulier

12/21/2006 1:57:00 AM

Looking for dns support, I found the gethostbyname method as a class
method of TCPSocket in the socket library.

Seems like an odd place, considering that gethostbyname is hardly
specific to TCP protocol alone.

Any idea why it was put there?

Cheers,
Mike

2 Answers

gga

12/21/2006 3:28:00 AM

0


msoulier ha escrito:

> Looking for dns support, I found the gethostbyname method as a class
> method of TCPSocket in the socket library.
>
> Seems like an odd place, considering that gethostbyname is hardly
> specific to TCP protocol alone.
>
> Any idea why it was put there?
>

It wasn't. It's part of Socket, which seems rather logical. TCPSocket
just inherits from Socket.

Eric Hodel

12/21/2006 3:28:00 AM

0

On Dec 20, 2006, at 18:00, msoulier wrote:

> Looking for dns support, I found the gethostbyname method as a class
> method of TCPSocket in the socket library.

$ ruby -rsocket -e 'p TCPSocket.ancestors'
[TCPSocket, IPSocket, BasicSocket, IO, File::Constants, Enumerable,
Object, Kernel]

> Seems like an odd place, considering that gethostbyname is hardly
> specific to TCP protocol alone.
>
> Any idea why it was put there?

It wasn't.

$ ruby -rsocket -e 'p Socket.gethostbyname("localhost")'
["localhost", [], 30, "\000\000\000\000\000\000\000\000\000\000\000
\000\000\000\000\001"]

--
Eric Hodel - drbrain@segment7.net - http://blog.se...

I LIT YOUR GEM ON FIRE!