Created
August 27, 2017 13:30
-
-
Save robodhruv/c91dbec2e631a74790d6d6436149aed5 to your computer and use it in GitHub Desktop.
Capture UDP packets on a port in JSON-like format.
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
# This program captures UDP packets on port identified in the variable | |
# port_no. The port will remain blocked until the script is killed. | |
from twisted.internet.protocol import DatagramProtocol | |
from twisted.internet import reactor | |
port_no = 5555; | |
class Echo(DatagramProtocol): | |
def datagramReceived(self, data, addr): | |
print("received %r from %s" % (data, addr)) | |
self.transport.write(data, addr) | |
reactor.listenUDP(port_no, Echo()) | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment