Question
You should use JAVA for this lab. Your TCP or UDP client/server will communicate over the network and exchange data. The server will start in
You should use JAVA for this lab. Your TCP or UDP client/server will communicate over the network and exchange data.
The server will start in passive mode listening on a specified port (use 32000 for example) for a transmission from a client. Separately, the client will be started and will contact the server on a given IP address and port number that must be entered via the command line. The client will pass the server a string consisting of a sequence of characters. If the string contains anything but numbers, the server will respond with Sorry, cannot compute! and exit. If the string contains all numbers, the individual digits will be added together and returned as a string (see below for an example). If the server sends a Sorry response to the client it will immediately exit. If the server receives a string of numbers, it will
(1) add the digits together,
(2) send the value back to the client,
(3) will not exit unless the response is a single digit.
This process will be repeated until there is only one digit remaining. Note: the server will send a new packet each time Step (2) is executed, and the client will expect to receive
a packet until there is only a single digit.
See below for the exact output.
Examples
Starting the Server Assume that you started a server on a machine with IP address 128.111.49.44, listening to port number 32000. The syntax should look like the following: machine1> ServerXXX 32000 o In this example, ServerXXX should be replaced by one of the names (ServerUDP or ServerTCP) given below in the Submission section. o The server should not produce any output but should end after interacting with a client.
Starting the Client machine2> ClientXXX 128.111.49.44 32000
o In this example, ClientXXX should be replaced by one of the names (CleintUDP or ClientTCP) given below in the Submission section.
Client Input / Output for Non-Numeric Example
machine2> ClientXXX 128.111.49.44 32000 Enter string: I don't like addition!! From server: Sorry, cannot compute! machine2>
Client Input / Output for Numeric Example
machine2> ClientXXX 128.111.49.44 32000 Enter string: 123456789101234567891012345678910 From server: 138 From server: 12 From server: 3 machine2>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started