-
-
Save jvns/aa202b1edd97ae261715c806b2ba7d39 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' | |
sock = UDPSocket.new | |
sock.bind('0.0.0.0', 12345) | |
sock.connect('8.8.8.8', 53) | |
# decode hex | |
hex_string = "b96201000001000000000000076578616d706c6503636f6d0000010001" | |
bytes = [hex_string].pack('H*') | |
sock.send(bytes, 0) | |
# receive reply | |
reply, _ = sock.recvfrom(1024) | |
puts reply.unpack('H*') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment