Created
April 16, 2011 16:40
-
-
Save yoggy/923261 to your computer and use it in GitHub Desktop.
UDP packet recieve test code...
This file contains hidden or 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
#!/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