# Dynamic status updates using net-mdns bonjour messaging

**URL:** <https://www.ruby-forum.com/t/dynamic-status-updates-using-net-mdns-bonjour-messaging/50538>\
**Category:** Ruby\
**Created:** [December 17, 2005, 10:16pm UTC](https://www.ruby-forum.com/t/dynamic-status-updates-using-net-mdns-bonjour-messaging/50538 "2005-12-17T22:16:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doug\_Beaver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@Doug\_Beaver](https://www.ruby-forum.com/u/Doug_Beaver)\
**Post date:** [December 17, 2005, 10:16pm UTC](https://www.ruby-forum.com/t/dynamic-status-updates-using-net-mdns-bonjour-messaging/50538/1 "2005-12-17T22:16:06Z")

</div>

hello,

i’m exploring using net-mdns 0.2 (written by sam roberts) to do some  
bonjour work. i’m curious if anyone has figured out how to make a  
bonjour service dynamically update its TXT record.

i’m starting to write a dummy chat client/server just to test the apis  
out, and while i can easily find lists of all the servers out there, i’m  
having difficulty getting my servers to broadcast updates about their  
status.

here’s a hack i did in order to simulate dynamic updates, i just create  
a new service each time i want to send an update:

* * *

require ‘net/dns/resolv-mdns’  
require ‘net/dns/resolv-replace’  
require ‘net/http’

args = [“service1”, “\_chatter.\_tcp”, 8000, nil]

i = 0  
announce = nil

loop do  
announce.stop unless announce.nil?  
announce = Net::DNS::MDNS::Service.new(\*args) do |s|  
s.ttl = 5  
s[“status”] = i.to\_s  
end

i += 1  
sleep 1  
end

* * *

i’m using mdns-watch.rb from net-mdns’s samples/ directory, and i see  
the proper TXT updates going out, but i’m wondering if there’s a way to  
do this without having to stop the service every time.

i tried just doing ‘announce[“status”] = i.to\_s’ inside my loop, but i  
never see updates, the only way i could make the bonjour records get  
broadcast was to create a new service object every time.

does anyone have any suggestions? btw, thanks to sam for creating such  
a cool module, i’m having a lot of fun working with it.

doug
