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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

============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====================

 

The following is a sender side Python Code to send a file “MyFile.txt"
from the sender to a receiver for 100 times.
The sender IP address is "192.168.0.27", and the receiver IP address is
"192.168.0.18".
Please Fill up the blanks with appropriate code to make the file transfer
successful.
Transcribed Image Text:The following is a sender side Python Code to send a file “MyFile.txt" from the sender to a receiver for 100 times. The sender IP address is "192.168.0.27", and the receiver IP address is "192.168.0.18". Please Fill up the blanks with appropriate code to make the file transfer successful.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education