import socket from datetime import datetime #initializing host, port, filename, total time and number of times to send the file host = '____________' port = 9000 fileName = "______" totalTime = 0 numTimesSend = 100 print('I am connecting to
============Code Begin=================
import socket
from datetime import datetime
#initializing host, port, filename, total time and number of times to send the file
host = '____________'
port = 9000
fileName = "______"
totalTime = 0
numTimesSend = 100
print('I am connecting to server side: ', host,'\n')
#using a for loop to send the file 100 times
for x in range(__________):
#recording the start time
startTime = datetime.now()
#connecting to the server
s = socket.socket()
s.________((host, port))
x+=1
print('I am sending file', fileName,' for the ',x,'th time')
#opening file to read
file_to_send = open(_________, 'rb')
#reading the first 1024 bits
data = file_to_send.read(1024)
while ______:
s.send(______)
#reading the next 1024 bits
data = file_to_send.read(______)
print('I am finishing sending file', fileName,' for the ',x,'th time')
file_to_send._______
#recording the end time
endTime = datetime.now()
timeTaken = int((endTime - startTime).total_seconds() * 1000)
totalTime += timeTaken
print('The time used in millisecond to receive ', fileName ,' for ', x,'th time is: ',timeTaken,"\n")
s.______
print('The average time to receive file ',fileName,' in millisecond is: ',totalTime/numTimesSend)
print('Total time to receive file ',fileName,' for ',numTimesSend,' times in millisecond is: ',totalTime)
print('I am done')
===========Code End====================
Trending now
This is a popular solution!
Step by step
Solved in 2 steps