Class: DNSSD::Reply::Browse

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

Overview

Returned by DNSSD::Service#browse

Instance Attribute Summary collapse

Attributes inherited from DNSSD::Reply

#flags, #interface, #service

Instance Method Summary collapse

Methods inherited from DNSSD::Reply

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

Constructor Details

#initialize(service, flags, interface, name, type, domain) ⇒ Browse

Creates a new Browse, called internally by DNSSD::Service#browse



24
25
26
27
28
# File 'lib/dnssd/reply/browse.rb', line 24

def initialize(service, flags, interface, name, type, domain)
  super service, flags, interface

  set_names name, type, domain
end

Instance Attribute Details

#domainObject (readonly)

A domain for registration or browsing



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

def domain
  @domain
end

#nameObject (readonly)

The service name



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

def name
  @name
end

#typeObject (readonly)

The service type



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

def type
  @type
end

Instance Method Details

#connect(family = Socket::AF_UNSPEC, addrinfo_flags = 0) ⇒ Object

Resolves this service’s target using DNSSD::Reply::Resolve#connect which connects, returning a TCP or UDP socket.



34
35
36
37
38
39
40
41
42
43
# File 'lib/dnssd/reply/browse.rb', line 34

def connect(family = Socket::AF_UNSPEC, addrinfo_flags = 0)
  value = nil

  DNSSD.resolve! name, type, domain do |reply|
    value = reply
    break
  end

  value.connect family, addrinfo_flags
end

#inspectObject

:nodoc:



50
51
52
53
54
# File 'lib/dnssd/reply/browse.rb', line 50

def inspect # :nodoc:
  "#<%s:0x%x %p interface: %s flags: %p>" % [
    self.class, object_id, fullname, interface_name, @flags
  ]
end

#resolveObject



45
46
47
48
# File 'lib/dnssd/reply/browse.rb', line 45

def resolve
  service = DNSSD::Service.resolve name, type, domain
  service.first
end