Created: 2008-10-19 01:51
Updated: 2017-11-09 05:14
License: mit



by Matthew Lyon


Datagrammer helps take the pain out of UDP by mitigating some of the packet encoding/decoding stuff, as well as providing a non-blocking listening thread.


  • Encodes/Decodes OSC-style packets (where a main 'address' is given along with typed arguments)
  • Listens for messages in its own thread, performs a callback when a message is received.
  • Has a default "speaking" address / port for talkback. the IP of the sender of a received packet is also made available to the callback.


require 'datagrammer'

server =
server.register_rule /.*/, lambda {|msg| server.speak("received: #{msg.join(',')}") }

# set to speak at server's default speak destination
client =, :speak_port => 5000)
client.register_rule 'received:', lambda {|msg| puts "rec'd #{msg}.join(' ')" }

client.speak(%w(hey joe))
sleep 0.1
# rec'd received: hey, joe


  • Rspec, if you wish to run the spec suite
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more