Skip to content

Instantly share code, notes, and snippets.

@edwardloveall
Last active August 29, 2015 14:10
Show Gist options
  • Save edwardloveall/eb082dffd1b30411260e to your computer and use it in GitHub Desktop.
Save edwardloveall/eb082dffd1b30411260e to your computer and use it in GitHub Desktop.
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
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