On 11/14/06, David Turnbull <[EMAIL PROTECTED]> wrote:
Socket.getaddrinfo(Socket.gethostname, nil) will still have to
resolve a name. It's more correct than hackish; but isn't
appropriate for peering into layer 3. If you recall the OSI model
you'll find Ruby is mostly suited for working at layers 5-7. Even
layer 5 is problematic for Ruby as is indicated by the popularity of
tools like Mongrel and EventMachine. This is why you keep feeling
the urge to drop out of Ruby -- it wasn't designed at all for layer 3.
If you're having deployment issues you should try to change the app
so that it doesn't depend on the specifics of OS managed layers.
Though this may be impossible if you're writing certain types of
administration tools.
One last try, http://ruby-sysutils.sourceforge.net/host.html
I found a C extension, however I am still receiving the same localhost
response. I did not realize FQDN and DNS were requirements for
looking up an IP address bound to a local interface.
Thanks, David for your insight.
Aaron
-david
> On 11/14/06, Aaron Johnson <[EMAIL PROTECTED]> wrote:
>> Is there an operating system independent way in ruby to determine the
>> IP address currently bound to any local ethernet interface? I would
>> like a way to find it that does not require DNS lookup or any network
>> query for that matter. The equivalent of 'ifconfig' for unix and
>> 'ipconfig' for windows wrapped up into one line of ruby that doesn't
>> use system(). This would help with some cross platform server
>> deployment issues.
>
> On Nov 14, 2006, at 11:46 AM, Lennon Day-Reynolds wrote:
> This is hackish in the extreme, but it's what comes to mind at the
> moment:
>
> Socket.getaddrinfo(Socket.gethostname, 'www').map {|ainfo| ainfo
> [3] }.uniq
_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby