Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'socket.so'
- class UDPServer
- def initialize(port)
- @port = port
- end
- def start
- @socket = UDPSocket.new
- @socket.bind('', @port) # Bind to 0.0.0.0
- while true
- packet = @socket.recvfrom(1024)
- puts packet
- end
- end
- end
- server = UDPServer.new(54321)
- server.start
Add Comment
Please, Sign In to add comment