In this assignment, you design a simple chat room in the form of a network application which uses the services of a TCP/IP computer network. Your design should have a clientserver architecture in which the server is multi-threaded. Then, you need to implement the server-side of the chat-room application in Java (implementing the client-side is optional). The server maintains a list (an ArrayList will work well) of all the active connections. It will listen on a port for a new connection. You should choose a specific port number and design an appropriate application-layer protocol (i.e. a list of commands and responses) for client-server communication. When a client enters the chat-room, the server establishes a new TCP/IP connection with the client and spawns a thread to handle that connection and the socket attached to it. Then, the main thread of server resumes listening to accept more clients. The spawned thread starts communication with the client by asking for its username using the newly generated socket. When the client responds, the connection information is added to the master list of chat room occupants. From that point on, anything that is typed by the client is relayed to all chat room occupants (including the client itself), with the username identifying the client. Of course if null is read from the client, or the special value LOGOUT then the client has disconnected and you should remove the connection from the shared ArrayList of active connections and then exit the thread gracefully (i.e. stop the infinite loop in the run method). Don’t worry too much about error checking. However, you will need to be careful to synchronize access to the array list using locks (or other mechanisms for preventing simultaneous access to a shared resource), since otherwise you might delete an entry while another thread is trying to broadcast to everyone, potentially resulting in an out-of-bounds ArrayList access or worse. You can test the server by imitating multiple clients using several telnet windows. (You can turn the echo on for the telnet windows to see what you are typing.) The server broadcasts a welcome message when a client first joins the chatroom, and then broadcasts another message when the client leaves the chatroom (in the finally block, after adjusting the ArrayList, but immediately prior to terminating the run method).
TCP/IP model layers
TCP/IP functionality is divided into four layers, each of which include specific protocols.
In this assignment, you design a simple chat room in the form of a network application which uses the services of a TCP/IP computer network. Your design should have a clientserver architecture in whic...
166 Chapter 8: TCP/IP Applications Getting Down to Business The way network communication all those ls and Os) goes in and out of a machine physically is through the NIC (network interface card). The way network communication goes in and out of a machine logically though, is through a program or service. A service is a program that runs in the background, independent of a logon, that provides functionalities to a system. Windows client machines, for instance, have a Workstation...
Project Description In this project, you will be developing a multithreaded Web server and a simple web client. The Web server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer Protocol). Requirements for the Web server The server is able to handle multiple requests concurrently. This means the implementation is multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an HTTP request, the server sets up a TCP connection to...
Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array of struct student_info ( char abc123171 char name [101 double GPA; To simplify the tasks, the server should create a static array of 10 students with random abc123, name, and GPA in the server program. Then the server waits for clients. When a client...