Chat with us, powered by LiveChat The purpose of this Challenge is for you to gain insights into the mechanics of establishing sockets and their operation. Although this Challenge is to be exec - Essayabode

The purpose of this Challenge is for you to gain insights into the mechanics of establishing sockets and their operation. Although this Challenge is to be exec

 

The purpose of this Challenge is for you to gain insights into the mechanics of establishing sockets and their operation.

Although this Challenge is to be executed on one machine (your's; aka 'localhost,' or 127.0.0.1), it is conceptually similar to executing socket programs across multiple computers connected via a network.

PREPARATION

  1. Read all of Chap 4 (Interprocess Communication) BEFORE attempting this Challenge.
  2. Be sure you have a sound understanding of 'localhost' (127.0.0.1). You should be knowledgeable regarding the purpose of localhost AND WHERE localhost IS DEFINED ON YOUR MACHINE!
  3. Download, save, and view the "Socket Demo Execution" video; here's the link

 

INSTRUCTIONS

  1. Download and save both the socket_server_student.py and the socket_client_student.py files into the SAME folder/directory.
  2. Be sure you know the path to both files.
  3. Open two Terminals/Command Lines. One is for the client program; the other for the server program.
  4. In your OS' Terminal/Command Line, navigate to the folder where the files are located.
  5. In their various Terminal/Command Line environments, inspect both programs; there are purposeful errors (and possibly omissions) present in the files.
  6. Notice Line 23 in the 'client' program: BE SURE YOU UNDERSTAND the purpose and meaning of the 'b' preceding the message string!
  7. Use a Text Editor and remedy the errors and omissions.
  8. As shown in the Demo Video, first start the server program from the Terminal/Command Line.
    • NOTE: You are LIKELY (but not guaranteed) to encounter a firewall message from your OS (macOS or Windows).
    • If you do, allow the program to gain the otherwise restricted access.
  9. Start the client program from its Terminal/Command Line.
  10. Observe the results and take two screenshots; one for the server, the other for the client.
  11. List the contents of the directory.
  12. Print (e.g., cat in macOS; type in Windows) the file: CIS64E_socket_server_demo_output.dat
  13. Take a screenshot of the contents of CIS64E_socket_server_demo_output.dat
  14. Upload your working programs and screenshots into Canvas.

WRITTEN RESPONSE

In the space provided below, answer this question: Assuming the programs properly execute and a socket is formed, what is being transmitted from client to server (1 word, 7 letters)?

#!/usr/bin/python3 __author__ = 'Rick Hubbard' # Developed for DeAnza College CIS64E # localhost (127.0.0.1) Socket Client import socket size = 512 host = '' #Will default to localhost (127.0.0.1) port = 9242 #Arbitrary port selection #Define Socket Family as Internet and Type as TCP (i.e., Socket Stream) socket_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #Define a Python tuple with coordinates to the server server_coordinates = (host, port) #[Attempt to] Connect with the server socket_client.connect(server_coordinates) #If connection with server was successful, then send a message as a BYTE string (not chr string) try: message = b' This is an example of sending a message via a socket from a client to a servern' #Ideally, message will be sent from client to server via the provisioned socket and server will process message socket_client.sendall(message) except socket.errno as e: #If message send was unsuccessful, capture error message print("Socket error ", e) #Display error message finally: socket_client.closer() #When doen, always Close() sockets!

,

#!/usr/bin/python3 __author__ = 'Rick Hubbard' # Developed for DeAnza College CIS64E # localhost (127.0.0.1) Socket Server import socket size = 512 host = '' #Will default to localhost (127.0.0.1) port = 9242 #Arbitrary port selection #Define Socket Family as Internet and Type as TCP (i.e., Socket Stream) socket_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #Options for Socket socket_server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #Bind socket to a specific IP address and port socket_server.bind((host, port)) #Is anyone there? socket_server.listen(5) #When a connection is successful (that is, a 'client' connects with this server), # then store data about the client c, addr = socket_server.accept() #Receive message (data) from client message = c.recv(size) if message: f_out = open("CIS64E_socket_server_demo_output.dat", '+w') #Create an output file for posterity print("Connection established with: ", addr[0]) f_out.write(addr[0]) f_out.write(":") f_out.write(message.decode("utf-8")) f_out.close() #When doen, always Close() files! socket_server.closer() #When doen, always Close() sockets!

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?