Run the server program and determine the IP address of the host that is running the server
Fantastic news! We've Found the answer you've been seeking!
Question:
Run the server program and determine the IP address of the host that is running the server (e.g., 128.238.251.26). To verify that we actually received the contents of the HTML file from the server.
Transcribed Image Text:
#import socket module from socket import import sys # In order to terminate the program serverSocket = socket (AF_INET, SOCK_STREAM) #Prepare a sever socket #Fill in start serverSocket.bind(', serverPort)) serverSocket.listen(1) #Fill in end while True: #Establish the connection print('Ready to serve...') connectionSocket, addr = serverSocket.accept() try: message = connection.Socket.recv(1024) filename message.split() [1] f = open(filename[1:]) outputdata = f.read() f.close() #Send one HTTP header line into socket #Fill in start connectionSocket.send(' HTTP/1.1 200 OK ') #Fill in end #Send the content of the requested file to the client for i in range(0, len(outputdata)): connectionSocket.send(outputdata[i].encode()) connectionSocket.send(" ".encode()) connectionSocket.close() except IOError: #Send response message for file not found #Fill in start connectionSocket.send(" HTTP/1.1 404 Not Found') #Fill in end #Close client socket #Fill in start connectionSocket.close() #Fill in end serverSocket.close() sys.exit() #Terminate the program after sending the corresponding data #import socket module from socket import import sys # In order to terminate the program serverSocket = socket (AF_INET, SOCK_STREAM) #Prepare a sever socket #Fill in start serverSocket.bind(', serverPort)) serverSocket.listen(1) #Fill in end while True: #Establish the connection print('Ready to serve...') connectionSocket, addr = serverSocket.accept() try: message = connection.Socket.recv(1024) filename message.split() [1] f = open(filename[1:]) outputdata = f.read() f.close() #Send one HTTP header line into socket #Fill in start connectionSocket.send(' HTTP/1.1 200 OK ') #Fill in end #Send the content of the requested file to the client for i in range(0, len(outputdata)): connectionSocket.send(outputdata[i].encode()) connectionSocket.send(" ".encode()) connectionSocket.close() except IOError: #Send response message for file not found #Fill in start connectionSocket.send(" HTTP/1.1 404 Not Found') #Fill in end #Close client socket #Fill in start connectionSocket.close() #Fill in end serverSocket.close() sys.exit() #Terminate the program after sending the corresponding data
Expert Answer:
Answer rating: 100% (QA)
Solution To run the server program and determine the IP address of the host that is running the serv... View the full answer
Related Book For
Computer Networking A Top-Down Approach
ISBN: 978-0136079675
5th edition
Authors: James F. Kurose, Keith W. Ross
Posted Date:
Students also viewed these programming questions
-
Ming Chen started a business and had the following transactions in June. a. Owner invested $61,000 cash in the company along with $13,000 of equipment in exchange for its common stock. b. The company...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
In the Internet File Server example (Figure 6-6), can the connect( ) system call on the client fail for any reason other than listen queue being full on the server? Assume that the network is...
-
Is the answer correct? The graph of a y = f(x) is shown. 6 + 5 14 m ~ 1 -6 -5 -4 -3 2 -1 -1 -2 -3 A w -4 -5- -6+ 1 2 3 4 The domain of f(x) is x = [-3,3] The domain of g(x) = notation) S 6 f(x) is a ...
-
Two thin parallel slits are made in an opaque sheet of film. When a monochromatic beam of ligbt is shone through them at normal incidence, the first bright fringes in the transmitted light occur in...
-
Activity 2 Directions: Choose a multimedia format to creatively present your experiences in life and tell how you feel about it using the pencil pictures below. Notes to the Teacher If the learner...
-
Comment on the following field situations and make recommendations for corrective action. a. One of the interviewers has an excessive rate of refusals in in-home personal interviewing. b. In a CATI...
-
Did Crosstown have a valid contract with Borman concerning the use of the crane? If so, was it a bilateral or a unilateral contract? Explain. Grant Borman, who was engaged in a construction project,...
-
Question 22 Daffodil Corporation had the following information this year: Account Sales Gain on Sale of Truck Sales Discounts COGS Expenses Loss on Flood Damage Dividends Declared Unearned Revenue...
-
Not all potentially good employees have a bubbly, goofy personality of the type that Zappos likes to attract. Would it be wise for the company to reject a candidate solely on the basis of a shy,...
-
the case of phar-mor inc. which can be accessed through the devry online library. in 3-4 pages (12-pt type, double-spaced, apa style for general format and citations) summarize the case and answer...
-
Stylist Services Co. offers its services to individuals desiring to improve their personal images. After the accounts have been adjusted at July 31, the end of the fiscal year, the following balances...
-
Gable Company uses three activity pools. Each pool has a cost driver. Information for Gable Company follows: Activity Pools Machining Designing costs Setup costs Total Cost of Pool $ 416,700 Cost...
-
Gable Company uses three activity pools. Each pool has a cost driver. Information for Gable Company follows: Activity Pools Machining Designing costs Setup costs Total Cost of Pool $ 416,700 93,100...
-
Keller Company makes two models of battery-operated boats, the Sandy Beach and the Rocky River. Basic production information follows: Direct materials cost per unit Direct labor cost per unit Sales...
-
Blossom Company produces flash drives for computers which have variable costs of $5 per flash drive to produce. Each flash drive sells for $10 each. During the current month, 1240 flash drives were...
-
Complete the sentence. Depository institutions provide four benefits, which are ______. A. creating liquidity, lowering the cost of borrowing, paying interest on investment funds, and introducing new...
-
Time Travel Publishing was recently organized. The company issued common stock to an attorney who provided legal services worth $25,000 to help organize the corporation. Time Travel also issued...
-
Is it possible for an organization's Web server and mail server to have exactly the same alias for a hostname (for example, foo. com)? What would be the type for the RR that contains the host name of...
-
In our discussion of how the VLR updated the HLR with information about the mobile s current location, what are the advantages and disadvantages of providing the MSRN as opposed to the address of the...
-
Why are policy considerations as important for intra-AS protocols, such as OSPF and Rrp, as they are for an inter-AS routing protocol like BGP?
-
In the FRED database, find a variable that is available in both a seasonally adjusted form and a not seasonally adjusted form. Plot both over time and describe how large the seasonal variation in the...
-
How does each of the following variables behave over the business cycle? Develop graphs to show your results and give economic explanations. a. Real imports b. Federal government receipts c. Housing...
-
An economic variable is persistent if declines in the variable tend to be followed by more declines, and increases by more increases. This question asks you to study the persistence of the civilian...
Study smarter with the SolutionInn App