Assignment 8 Socket programming Solution

The goal of this assignment is to gain experience with network programming, specifically with  sockets in Java. This assignment will also require you to develop a server and client  simultaneously, which is an important skill in itself. The client will allow the user to enter an  arbitrary list of integers to be sent to the server. The server will then return a list of integers  containing only the prime numbers in the original list.
1. [20] Create two classes, one for your client and one for your server. Each class will need a  main method so that both classes can be executed.
2. [30] Implement your client to prompt the user to enter a list of integers. You can do this  however you’d like (e.g., command line, GUI). Send the list of integers to the server (hint: see  java.net.Socket), and then print the list of prime integers received.
3. [30] Implement your server to wait for a socket connection (hint: see java.net.ServerSocket).
When a socket is accepted, read a list of integers, determine which in the list are prime, and  then send a list containing the prime numbers back to the client. When choosing a data  structure and algorithm, take care to avoid unnecessary overhead (e.g., O(n)-time removal of  an item from the list). Your server may shut down after completing this process and does not  need to support multiple sequential connections.
4. [20] Write code that is clear and efficient. Specifically, your code should be indented with  respect to code blocks, avoid unnecessarily repetitive code, avoid code that is commented out  or otherwise unused, use descriptive and consistent class/method/variable names, etc.
5. [+10] (Extra credit) Add security by obfuscating the integers before they are sent over the  network and deobfuscating them when they arrive (both when sending from client to server  and from server to client). You may use any method of obfuscation you’d like, such as a simple
XOR or a Caesar Cipher.
Your client output should look something like:
Enter a number, blank line to quit:
3
Enter a number, blank line to quit:
4
Enter a number, blank line to quit:
5
Enter a number, blank line to quit:
6
Enter a number, blank line to quit:
7
Enter a number, blank line to quit:
client sent: [3, 4, 5, 6, 7]
client received: [3, 5, 7]
Zip the Assignment8 folder in your Eclipse workspace directory, name the .zip file <Your Full NameAssignment8.zip (e.g., EricWillsAssignment8.zip), and upload the .zip file to Canvas (see Assignments section for submission link).
Powered by