Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (47 sloc) 1.491 kb
import sys
import getopt
import Checksum
import BasicSender
'''
This is a skeleton sender class. Create a fantastic transport protocol here.
'''
class Sender(BasicSender.BasicSender):
# Main sending loop.
def start(self):
raise NotImplementedError
'''
This will be run if you run this script from the command line. You should not
need to change any of this.
'''
if __name__ == "__main__":
def usage():
print "BEARS-TP Sender"
print "-f FILE | --file=FILE The file to transfer; if empty reads from STDIN"
print "-p PORT | --port=PORT The destination port, defaults to 33122"
print "-a ADDRESS | --address=ADDRESS The receiver address or hostname, defaults to localhost"
print "-d | --debug Print debug messages"
print "-h | --help Print this usage message"
try:
opts, args = getopt.getopt(sys.argv[1:],
"f:p:a:d", ["file=", "port=", "address=", "debug="])
except:
usage()
exit()
port = 33122
dest = "localhost"
filename = None
debug = False
for o,a in opts:
if o in ("-f", "--file="):
filename = a
elif o in ("-p", "--port="):
port = int(a)
elif o in ("-a", "--address="):
dest = a
elif o in ("-d", "--debug="):
debug = True
s = Sender(dest,port,filename,debug)
try:
s.start()
except (KeyboardInterrupt, SystemExit):
exit()
Jump to Line
Something went wrong with that request. Please try again.