1. (Ensure that the user can pass only 0 or 1 to the server.) Test the operation of the server with two clients. Note that exercises 3.5 and 3.6 (especially the latter) are rather substantial tasks....

1. (Ensure that the user can pass only 0 or 1 to the server.) Test the

operation of the server with two clients. Note that exercises 3.5 and 3.6 (especially the latter) are rather substantial tasks.


2. Implement a basic electronic chatroom application that employs a


multithreaded server. Both server and client will need to be implemented and


brief details of these programs are provided below.


The multithreaded chat server must broadcast each message it receives to


all the connected clients, of course. It should also maintain a dynamic list of



Socket
references associated with those clients. Though you
could
use an


array to hold the list (with an appropriate over-allocation of array cells, to


cater for a potentially large number of connections), the use of a
Vector


object would be much more realistic. (If you are unfamiliar with
Vectors,


then refer to Section 4.8 in the next chapter.)


The client must be implemented as a GUI that can send and receive


messages until it sends the string 'Bye'. A separate thread will be required to


receive messages from the server and add them cumulatively to a text area.


The first two things that this thread should do are (i) accept the user's


chatroom nickname (probably via an input dialogue box) and (ii) send this


name to the server. All other messages should be sent via a text area and


associated button. As a simplification, assume that no two clients will select


the same nickname.


Note


It is likely that a
NoSuchElementException
will be generated at the line that


reads from the socket's input stream when the user's socket is closed (after sending 'Bye'), so place this reading line inside a try and have an empty catch.


May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here