def newCon(data, addr): sock = RSock(server, addr, cwnd, ploss, pcorr) packet = sock.receivePacket(data) if packet == None: # bad packet... return fileRequest(packet, sock) clients[addr] = sock sock.start()
def main(argv): try: port = int(argv[1]) host = argv[2] filename = argv[3] if len(sys.argv) > 4: cwnd = int(sys.argv[4]) else: cwnd = 0 if len(argv) > 5: ploss = int(argv[5]) else: ploss = random.randint(1, 40) if len(argv) > 6: pcorr = int(argv[6]) else: pcorr = random.randint(1, 40) except IndexError: print 'Usage: python client.py port host filename [prob. loss] [prob. corr]' sys.exit(-1) # create client socket client = socket(AF_INET, SOCK_DGRAM) sock = RSock(client, (host, port), cwnd, ploss, pcorr) sock.enqueuePacket(filename) print "Connecting to " + str(sock.addr) + " to ask for file " + filename t = Thread(target=recvFile, args=(filename, client, sock)) t.start() sock.start() t.join()