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

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top