Sha256: e769e044f953f1b420a3975fc54e90f77dfc4dfb755a07e8a17528b09064fea6

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

##
# Returned by DNSSD::Service#browse

class DNSSD::Reply::Browse < DNSSD::Reply

  ##
  # A domain for registration or browsing

  attr_reader :domain

  ##
  # The service name

  attr_reader :name

  ##
  # The service type

  attr_reader :type

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

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

    set_names name, type, domain
  end

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

  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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dnssd-3.0.2 lib/dnssd/reply/browse.rb
dnssd-3.0.1 lib/dnssd/reply/browse.rb
dnssd-3.0.0 lib/dnssd/reply/browse.rb