Created
October 17, 2013 15:08
-
-
Save nbari/7026621 to your computer and use it in GitHub Desktop.
python send UDP data on port 8000
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/env python | |
from socket import * | |
import sys | |
s = socket(AF_INET, SOCK_DGRAM) | |
host = sys.argv[1] | |
port = 8000 | |
buf = 1024 | |
addr = (host, port) | |
file_name = sys.argv[2] | |
s.sendto(file_name, addr) | |
f = open(file_name, "rb") | |
data = f.read(buf) | |
while (data): | |
if(s.sendto(data, addr)): | |
print "sending ..." | |
data = f.read(buf) | |
s.close() | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perl client to listen
run it using:
perl script.pl 8000