< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous (in thread)
N :the next (in thread)
|<:the top of this thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
On Wed, Nov 19, 2008 at 3:44 PM, Vladimir Fekete
<fekete / melkor.dnp.fmph.uniba.sk> wrote:
> Hello Alan,
>
> I think we don't understand each other. I don't need reverse DNS (I would use
> resolv.rb for it instead). What I need is:
>
> you have machine with fully qualified domain name (FQDN)
> a.b.c.d.e
> It's hostname is
> a
> It's IP is
> v.x.y.z
>
> I'm looking for function which could give me back fully qualified domain
> name and IP when I pass hostname as argument.
>
> Probably I don't understand what is canonical name I thought it should be FQDN
> but it is not.
>
> because this code:
>
> puts "getaddress : " + IPSocket.getaddress("a").inspect
> puts "gethostbyname : " + TCPSocket.gethostbyname("a").inspect
>
> has result:
>
> getaddress : "10.0.2.1"
> gethostbyname : ["a", [], 2, "10.0.2.1"]
>
> and what i need is result like this:
>
> gethostbyname : ["a.b.c.d.e", ["a"], 2, "10.0.2.1"]
>
> I hope it's more clear now. (or maybe I completely did not get what you
> wanted to tell me)
>
> Cheers,
>
> V.
>
TCPSocket.gethostbyname is confusingly inconsistent with Socket.gethostbyname.
I suggest always using the Socket version. I think it will work the way you
want it to.
Alternatively, the getaddrinfo method may do what you are looking for.
Technically getaddrinfo obsoletes gethostbyname, anyway. It looks like:
Socket.getaddrinfo(host, port [, family] [, socktype] [, protocol] [,
flags]) => resultsArray
The rules for using it are pretty complicated but you'll probably want to do
something like:
include Socket::Constants
p Socket.getaddrinfo('myhost', nil, AF_INET, SOCK_STREAM)
Note that in either case your reverse DNS lookup must be configured correctly
or all you will get is an ip address. You can test this using the nslookup
command from a command prompt in Linux or Windows.
--
Alan