Sha256: 6d8b7858b496fb346dcf76d7849e3baed0b6e5b77d29211d0546c0bb4ce7d2a9

Contents?: true

Size: 776 Bytes

Versions: 7

Compression:

Stored size: 776 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?

    resolver = DNSSD::Service.new
    resolver.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

    resolver.stop
  end

  services.clear

  puts
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
dnssd-1.4 sample/resolve.rb
dnssd-1.3.4 sample/resolve.rb
dnssd-1.3.3 sample/resolve.rb
dnssd-1.3.2 sample/resolve.rb
rackjour-0.1.8 vendor/gems/gems/dnssd-1.3.1/sample/resolve.rb
dnssd-1.3.1 sample/resolve.rb
dnssd-1.3 sample/resolve.rb