Last active
August 29, 2015 14:10
-
-
Save edwardloveall/eb082dffd1b30411260e to your computer and use it in GitHub Desktop.
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' | |
host = 'their.ip.address' | |
port = 33_333 | |
udpsock = UDPSocket.new | |
udpsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true) | |
loop do | |
data = gets.chomp | |
udpsock.send(data, 0, host, port) | |
break if data == '/quit' | |
end | |
udpsock.close |
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' | |
host = 'your.IP.address' | |
port = 33_333 | |
BasicSocket.do_not_reverse_lookup = true | |
udpsock = UDPSocket.new | |
udpsock.bind(host, port) | |
loop do | |
data, _ = udpsock.recvfrom(1024) | |
puts data | |
break if data == '/quit' | |
end | |
udpsock.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment