why is gethostbyname in TCPSocket?

M

msoulier

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
 
G

gga

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.
 
E

Eric Hodel

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"]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,843
Latest member
WizcraftEntertainmentAgen

Latest Threads

Top