Class: DNSSD::Reply::AddrInfo

Inherits:
DNSSD::Reply show all
Defined in:
lib/dnssd/reply/addr_info.rb

Overview

Created by DNSSD::Service#getaddrinfo

Instance Attribute Summary collapse

Attributes inherited from DNSSD::Reply

#flags, #interface, #service

Instance Method Summary collapse

Methods inherited from DNSSD::Reply

#fullname, #inspect, #interface_name, #protocol, #service_name, #set_fullname, #set_names

Constructor Details

#initialize(service, flags, interface, hostname, sockaddr, ttl) ⇒ AddrInfo

Creates a new AddrInfo, called internally by DNSSD::Service#getaddrinfo



29
30
31
32
33
34
35
36
37
# File 'lib/dnssd/reply/addr_info.rb', line 29

def initialize(service, flags, interface, hostname, sockaddr, ttl)
  super service, flags, interface

  @hostname = hostname
  @port, @address = Socket.unpack_sockaddr_in sockaddr

  @created = Time.now
  @ttl = ttl
end

Instance Attribute Details

#addressObject (readonly)

IP address of host



9
10
11
# File 'lib/dnssd/reply/addr_info.rb', line 9

def address
  @address
end

#hostnameObject (readonly)

Host name



14
15
16
# File 'lib/dnssd/reply/addr_info.rb', line 14

def hostname
  @hostname
end

#portObject (readonly)

Port name



19
20
21
# File 'lib/dnssd/reply/addr_info.rb', line 19

def port
  @port
end

#ttlObject (readonly)

Time to live see #expired?



24
25
26
# File 'lib/dnssd/reply/addr_info.rb', line 24

def ttl
  @ttl
end

Instance Method Details

#expired?Boolean

Has this AddrInfo passed its TTL?

Returns:

  • (Boolean)


42
43
44
# File 'lib/dnssd/reply/addr_info.rb', line 42

def expired?
  Time.now > @created + ttl
end