Sha256: 9a2e75abda2a653961e8ce189056b61c9f595284d00f390cd028ba50a1050e18

Contents?: true

Size: 733 Bytes

Versions: 5

Compression:

Stored size: 733 Bytes

Contents

require 'dnssd'

Thread.abort_on_exception = true
trap 'INT' do exit end
trap 'TERM' do exit end

puts "Resolving TCP blackjack services"
puts "(run sample/register.rb)"
puts

browser = DNSSD::Service.new
services = {}

browser.browse '_blackjack._tcp' do |reply|
  services[reply.fullname] = reply
  next if reply.flags.more_coming?

  services.sort_by do |_, service|
    [(service.flags.add? ? 0 : 1), service.fullname]
  end.each do |_, service|
    next unless service.flags.add?

    DNSSD::Service.new.resolve service do |r|
      puts "#{r.name} on #{r.target}:#{r.port}"
      puts "\t#{r.text_record.inspect}" unless r.text_record.empty?
      break unless r.flags.more_coming?
    end
  end

  services.clear

  puts
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dnssd-3.0.2 sample/resolve.rb
dnssd-3.0.1 sample/resolve.rb
dnssd-3.0.0 sample/resolve.rb
dnssd-2.0.1 sample/resolve.rb
dnssd-2.0 sample/resolve.rb