Parent

Methods

DNSSD::Reply::Resolve

Created by DNSSD::Service#resolve

Attributes

domain[R]

A domain for registration or browsing

name[R]

The service name

port[R]

The port for this service

target[R]

The hostname of the host provide the service

text_record[R]

The service’s primary text record

type[R]

The service type

Public Class Methods

new(service, flags, interface, fullname, target, port, text_record) click to toggle source

Creates a new Resolve, called internally by DNSSD::Service#resolve

    # File lib/dnssd/reply/resolve.rb, line 39
39:   def initialize(service, flags, interface, fullname, target, port,
40:                  text_record)
41:     super service, flags, interface
42: 
43:     set_fullname fullname
44: 
45:     @target = target
46:     @port = port
47:     @text_record = DNSSD::TextRecord.new text_record
48:   end

Public Instance Methods

connect(family = Socket::AF_UNSPEC, addrinfo_flags = 0) click to toggle source

Connects to this Reply. If # and # are missing, DNSSD.resolve is automatically called.

family can be used to select a particular address family (IPv6 vs IPv4).

addrinfo_flags are passed to DNSSD::Service#getaddrinfo as flags.

    # File lib/dnssd/reply/resolve.rb, line 58
58:   def connect(family = Socket::AF_UNSPEC, addrinfo_flags = 0)
59:     addrinfo_protocol = case family
60:                         when Socket::AF_INET   then DNSSD::Service::IPv4
61:                         when Socket::AF_INET6  then DNSSD::Service::IPv6
62:                         when Socket::AF_UNSPEC then 0
63:                         else raise ArgumentError, "invalid family #{family}"
64:                         end
65: 
66:     service = DNSSD::Service.new
67: 
68:     service.getaddrinfo target, addrinfo_protocol, addrinfo_flags,
69:                         @interface do |addrinfo|
70:       address = addrinfo.address
71: 
72:       begin
73:         socket = nil
74: 
75:         case protocol
76:         when 'tcp' then
77:           socket = TCPSocket.new address, port
78:         when 'udp' then
79:           socket = UDPSocket.new
80:           socket.connect address, port
81:         end
82: 
83:         return socket
84:       rescue
85:         next if addrinfo.flags.more_coming?
86:         raise
87:       end
88:     end
89:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.