


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



In this project, you are required to write the simple multicast chat system using JAVA. You need to write a centralized chat server and a chat client. The system should use a message passing system over sockets to allow multiple clients to chat with each other. There should be a central server that clients use to log into the system. From that point, the user should be able to chat with all other clients signed into the chat server.
You need to write a network-client that contacts your server, and lets the server know when the user logs in and out of the system. More specifically, your network-client needs to achieve the following requirements:
You need to write a server. This server must keep track of all users in your chat system. The server should be run on either apollon.cse.sc.edu or broad.cse.sc.edu. It should operate on a known port. You should choose a port and make sure that your client will connect to the right port.
You need to design your chat message format, including the sign-in message, sign-off message and regular message.
This project will count for 15 points toward your final grade. The programs will be graded based on the amount of the required functionalities that has been implemented (13 points), the quality of the code (2 points). You need to submit all the source code necessary to build your system, a Makefile, a README file and your report via the Dropbox named project04 before the due day. The README file should contain following information: 0) your name (graduate or undergraduate); 1) the programming environment you used; 2) how to compile your programs; 3) how to execute your programs; which machine should host your server. 4) the name of each file submitted along with a one line description of what is in the file; 5) If your code is not complete, tell me what works and what doesn't.
import java.net.; import java.io.;
public class MulticastSniffer {
public static void main(String[] args) {
InetAddress ia = null; byte[] buffer = new byte[65509]; int port = 0;
// read the address from the command line try { ia = InetAddress.getByName(args[0]); port = Integer.parseInt(args[1]); } // end try catch (Exception e) { System.err.println(e); System.err.println("Usage: java MulticastSniffer MulticastAddress port"); System.exit(1); }
try { MulticastSocket ms = new MulticastSocket(port); ms.joinGroup(ia); while (true) { DatagramPacket dp = new DatagramPacket(buffer, buffer.length); ms.receive(dp); String s = new String(dp.getData(), 0, 0, dp.getLength()); System.out.println(s); } } catch (SocketException se) { System.err.println(se); } catch (IOException ie) { System.err.println(ie); }