Sending UDP packets with fixed source port

I needed to send UDP packets from my Ruby application, with fixed source port, but not in response to other packets. Well it turned out You need create UDP server, and then send packets:

s=UDPSocket.new
s.bind('192.168.248.128',5000)
ar = [1000,24,12,3,100,1]
s.send(ar.pack("L6"), 0, "192.168.248.1", 5000)

That’s it!

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.