Skip to content

Instantly share code, notes, and snippets.

@DannyBen
Created August 26, 2018 07:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DannyBen/662663c9eb5900e529698f202d4ab178 to your computer and use it in GitHub Desktop.
Save DannyBen/662663c9eb5900e529698f202d4ab178 to your computer and use it in GitHub Desktop.
Ruby UDP Example
require 'socket'
title "UDP Test"
action :server do
s = UDPSocket.new
s.bind(nil, 1234)
5.times do
text, sender = s.recvfrom(16)
puts "received #{text} from #{sender}"
end
end
action :client do
s = UDPSocket.new
s.send("hello", 0, 'localhost', 1234)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment