Created
August 15, 2014 07:27
-
-
Save tai2/b24cce452fc620d3ed33 to your computer and use it in GitHub Desktop.
Send a udp packet
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
#!/usr/bin/python | |
import socket | |
import sys | |
if __name__ == '__main__': | |
if len(sys.argv) < 3: | |
sys.stderr.write('require arguments. host port filename') | |
sys.exit(1) | |
host = sys.argv[1] | |
port = int(sys.argv[2]) | |
filename = sys.argv[3] | |
msg = open(filename, 'r').read() | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
addr = (host, port) | |
sock.sendto(msg, addr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment