5

Neither

Resolv.getname( "fred.local" ) 
Resolv.getaddress( "10.0.1.18" )

nor

Socket.gethostbyaddr([10,0,1,18].pack("CCCC")) 

seem to recognize hosts on the local subnet which use zeroconf/bonjour. I need to find the hostname of a zeroconf computer on the local subnet given its ip address.

Uilleann
  • 506
  • 4
  • 14
  • Perhaps something like this: `h_n = Socket.getaddrinfo('10.0.1.18', nil)` might work. The hostname should be located at: `h_n[0][2]` – fmendez Apr 09 '13 at 15:38
  • Just returns '10.0.1.18' as the hostname...[["AF_INET", 0, "10.0.1.18", "10.0.1.18", 2, 2, 17], ["AF_INET", 0, "10.0.1.18", "10.0.1.18", 2, 1, 6]] – Uilleann Apr 09 '13 at 15:46

2 Answers2

1

Those function speak regular TCP and DNS, I would assume you need to use a bonjour API, such as http://dnssd.rubyforge.org/

DGM
  • 26,629
  • 7
  • 58
  • 79
  • Didn't figure out how to get dnssd to do the name lookup. Tried the net-mdns gem, using Resolv::MDNS.getname( '10.0.1.18' ), which seems like it should work, returns that it can't find a name for the address. BTW, I can ping the ip address, and the local name 'fred.local' – Uilleann Apr 12 '13 at 02:12
0

Looks like the link from DGM's post stopped working and I don't have the rep for comments :)

https://github.com/tenderlove/dnssd

Chris Hein
  • 61
  • 2