Question

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...

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).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

TCP/IP model layers

TCP/IP functionality is divided into four layers, each of which include specific protocols.

  • The application layer provides applications with standardized data exchange. Its protocols include the Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP), Post Office Protocol 3 (POP3), Simple Mail Transfer Protocol (SMTP) and Simple Network Management Protocol (SNMP).
  • The transport layer is responsible for maintaining end-to-end communications across the network. TCP handles communications between hosts and provides flow control, multiplexing and reliability. The transport protocols include TCP and User Datagram Protocol (UDP), which is sometimes used instead of TCP for special purposes.
  • The network layer, also called the internet layer, deals with packets and connects independent networks to transport the packets across network boundaries. The network layer protocols are the IP and the Internet Control Message Protocol (ICMP), which is used for error reporting.
  • The physical layer consists of protocols that operate only on a link -- the network component that interconnects nodes or hosts in the network. The protocols in this layer include Ethernet for local area networks (LANs) and the Address Resolution Protocol (ARP).
Add a comment
Know the answer?
Add Answer to:
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...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT