Skip to content

Instantly share code, notes, and snippets.

@yoggy
Created April 16, 2011 16:40
Show Gist options
  • Save yoggy/923261 to your computer and use it in GitHub Desktop.
Save yoggy/923261 to your computer and use it in GitHub Desktop.
UDP packet recieve test code...
#!/usr/bin/ruby
#
# UDP packet recieve test...
#
require 'socket'
addr = '127.0.0.1'
port = 12345
puts "== create socket for recv =="
s = UDPSocket.new
s.bind(addr, port)
puts "== send test data =="
c = UDPSocket.new
c.send("hello " + Time.new.to_s, 0, addr, port)
10.times do
puts "== sleep =="
sleep 1
end
puts "== recv data =="
puts s.recv 1024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment