You are to create a direct messenger program. In particular, the program will perform as follows:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 <port number> ■ Java: $> java Messenger -1 <port number> o Usage as a client: ▪ Python: $ python messenger.py <port number> [<server address>] ■ Java: $> java Messenger <port number> [<server address>] 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. 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 <port number> ■ Java: $> java Messenger -1 <port number> o Usage as a client: ▪ Python: $ python messenger.py <port number> [<server address>] ■ Java: $> java Messenger <port number> [<server address>] 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.
Expert Answer:
Answer rating: 100% (QA)
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... View the full answer
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date:
Students also viewed these programming questions
-
Thornton Boat Company makes inexpensive aluminum fishing boats. Production is seasonal, with considerable activity occurring in the spring and summer. Sales and production tend to decline in the fall...
-
You are to create a direct messenger program. In particular, the program will perform as follows: It must behave as either a client or a server, depending on the command line arguments supplied when...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
Mickey Limited is a manufacturing business that uses a standard costing system. The companys flexed budget for April 20X9 is: Sales 173,340 Costs Direct materials (22,500) Direct labour (37,684)...
-
Interest during Construction Grieg Landscaping began construction of a new plant on December 1, 2010. On this date the company purchased a parcel of land for $139,000 in cash. In addition, it paid...
-
In Problems 1-3, use the vector forms of Green's Theorem to calculate (a) and (b) 1. F = y2i + x2j; C is the boundary of unit square with vertices (0, 0), (1, 0), (1, 1), and (0, 1). 2. F = ayi +...
-
Papa Johns International Inc., a large pizza chain, launched an advertising campaign with the new slogan, Better Ingredients. Better Pizza. Papa Johns placed the slogan on millions of signs, shirts,...
-
Paige, age 26, has purchased a new Ford sedan. She has a clean driving record. Collision coverage on the car in a small Midwestern city where she lives would cost approximately $630 every six months...
-
6. For the given first order reaction 7. AB The half life of the reaction is 0.3010 min. The ration of the initial concentration of reactant to the concentration of reactant at time 2.0 min will be...
-
Ryan is 26 years old and weighs 213 pounds. He works a full-time construction job during the day and squeezes in online classes at the community college in the evenings. He recently started working...
-
Calculate work in process and finished goods from job cost sheets. (LO 3, 5) Laubitz Company begins operations on April 1. Information from job cost sheets shows the following: Manufacturing Costs...
-
Find the antiderivative by using areas in Problems 9-22. \(\int(5 x+1) d x\)
-
Find the equation of the line tangent to \(y=x^{2}\) at \(x=1\).
-
Evaluate the area function for the functions given in Problems 1-8. Let \(y=x+5\); find \(A(x)\).
-
What is a derivative?
-
Find the antiderivative in Problems 13-14. \(\int 16 x d x \)
-
Which of the following is an isotope of Lithium. You can use the holotable or images to help you. a) A lithium atom with an atomic number of six and a mass number of seven b) A lithium atom with an...
-
Evaluate the function at the given value(s) of the independent variable. Simplify the results. (x) = cos 2x (a) (0) (b) (- /4) (c) (/3) (d) ()
-
Define the difference between predecessors and successors that are comprised within a WBS.
-
What is the concept called when someone gains unauthorized entry by closely following another person through a secure entrance using their credentials to bypass a control point? a. Tailgating b....
-
Which of the following terms describes the process of making and using codes to secure the transmission of information? a. Algorithm b. Cryptography c. Steganography d. Cryptanalysis
-
Apple stock is selling for \($120\) per share. Call options with a \($117\) exercise price are priced at \($12.\) What is the intrinsic value of the option, and what is the time value?
-
Name five variables that can affect the price of options, and briefly explain how each affects prices. How important are intrinsic value and time value to in-the-money options? To out-of-the-money...
-
Twitter is trading at \($34.50.\) Call options with a strike price of \($35\) are priced at \($2.30\) . What is the intrinsic value of the option, and what is the time value?
Study smarter with the SolutionInn App