Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

You are to create a direct messenger program. In particular, the program will perform as follows: 1. It must behave as either a client

 

You are to create a direct messenger program. In particular, the program will perform as follows: 1. It must behave as either a client or a server, depending on the command line arguments supplied when started. 2. Specifically, the -1 option will direct the program to listen for connections, thereby acting as a server. If the -1 option is not present on the command line, your program will connect to a server, thereby acting as a client. 3. The port number must also be supplied as a command line argument. 4. Although your messenger may be hard-coded to connect only to localhost when acting as a client, you may include a server address on the command line as well, thereby permitting your messenger to connect between hosts. 5. The -1 option, if used, should be placed immediately after the name of the program and before the port number and server address arguments. 6. Once the client and server messengers are connected, either end can send text messages to the other end. 7. Messages must be provided to the program using standard input. 8. Immediately after receiving a message, the program must output the message to standard output. 9. The program is terminated by first shutting down sending, then closing the socket. Once one end shuts down, the other side will receive a zero-length message, informing it of the shut down. The other side must then shut down immediately. . Usage o Usage as a server: Python: $> python messenger.py -1 Java: $> java Messenger -1 o Usage as a client: Python: $ python messenger.py [ ] Java: $> java Messenger [ ] Testing and Assessment o Automated grading tools for this assignment are contained within the tar file tests-messenger.tar. Download the tar file from D2L and place it in the same directory as your code. Then, extract the grading files by using the following command in a terminal window: $> cd /path/to/my/code $> tar xvf tests-messenger.tar o There are two grading tools, test1 and test2, including their supporting scripts and files. o The first grading tool, test1, is designed to evaluate the basic operation of your code. o If your code passes test1, it outputs the message: test1 terminated properly If your code fails test1, however, an appropriate error message is output. In that case, your grade for the exercise is zero (0) points! o Thus, your code must pass test1 in order to earn any points! o Assuming that your code passes test1, test2 conducts additional tests and awards points. In that case, your grade for this exercise are the points awarded by test2. o If you are using Python, the grading tools expect the name of your program to be messenger.py O If you are using Java, the grading tools expect the name of your program to be Messenger.class o Note: If you are using Java, you must compile your code before running the grading tools. The grading tools will not compile your Java code. o Run the test1 tool from the command line. If your code was written in Python, start test1 as follows: $>py test1-messenger-py.py o If your code was written in Java, start test1 as follows: $ py test1-messenger-java.py o If your code passes test1, run the test2 tool from the command line. If your code was written in Python, start test2 as follows: $>py test2-messenger-py.py o If your code was written in Java, start test2 as follows: $ py test2-messenger-java.py o If it runs successfully, the test2 tool will output the total number of points earned. o If test2 fails, an error message will be displayed and no points are earned. o This exercise is worth 10 points.

Step by Step Solution

3.46 Rating (146 Votes )

There are 3 Steps involved in it

Step: 1

Solution serverpy Import the necessary libraries import socket import sys import select Take message from an host and send it to all others def shouts... blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Information Security

Authors: Michael E. Whitman, Herbert J. Mattord

7th Edition

035750643X, 978-0357506431

More Books

Students explore these related Programming questions