1

I am new to ruby and its library, but how do i combine DNSSD and TCPServer together?

I know i can register DNSSD service via

registration = DNSSD.register("My Files", hostname, "local.", port) 

And I can create a DNSSD service for my TCPServer this way, but how do i specify the hostname (service name) as the above?

server = TCPServer.open(port)
DNSSD.announce server, 'my awesome HTTP server'

I want to broadcast my server, so that the client can resolve the DNSSD service and establish a connection.

Pardon me if thats a stupid question.

perwyl
  • 323
  • 3
  • 14

1 Answers1

0

I manage to setup it up via

  1. Register a DNSSD aka Bonjour Service
DNSSD.register("", hostname, "local.", port) do |register_reply|
puts "Registration result: #{register_reply.inspect}"
end 
  1. Setup TCPServer to listen on the same port
blackjack = TCPServer.open("",port)
loop do
socket = blackjack.accept
peeraddr = socket.peeraddr
puts "Connection from %s:%d" % socket.peeraddr.values_at(2, 1)
end
perwyl
  • 323
  • 3
  • 14