Created
August 26, 2018 07:30
-
-
Save DannyBen/662663c9eb5900e529698f202d4ab178 to your computer and use it in GitHub Desktop.
Ruby UDP Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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