Programming Assignment #1

Instant Messaging Server

Your job is to write a Java application that will act as a the server for an Instant Messaging application. Clients will connect to the server [using a TCP connection] to talk to each other. Clients will type messages that are composed of one or more lines of text. Each time a user types a new line of text at the keyboard, that line will be transmitted to the server.

Each time the server receives a new line from any client, it will send a copy to all the clients but the one who sent it (i.e. to prevent a confusing double echo on the sending-client side).

Any client that wants to abandon the service MUST type a line with the text QUIT. Whenever the server receives such a line of text it will interpret its meaning, closing the socket this client was using. From them on, no attempt to send any more data to that client will happen (note: trying to send data to an already closed socket would trigger an exception).

Still, a client could leave the service by just closing the connection without the mandatory QUIT command. You do not need to manage that case though.

Your Code

Your code has to conduct the following tasks:

  1. Accept any number of simultaneous clients, but it is safe to assume no more than one hundred simultaneous clients.

  2. Retransmit any text line, including empty lines, to any active client but the one typing that text line.

  3. Not to retransmit those lines which only contents is the QUIT command. Any combination of upper and lower case characters should be accepted and recognized (i.e: both QuiT and quit should work too).

  4. The server program prints “NEW CLIENT” whenever a new client connects to the server and it prints “CLIENT GONE” when any client quits the system.

Some tips

  • Server listens on port 7777

  • You may use several telnet windows as clients of your server (for testing purposes) by just typing;

telnet localhost 7777

Due date

Your Java source code has to be submitted by email (address available on the front page) by Nov 30th.

If you have any doubt about the assignment I strongly suggest you to stop by my office during office hours (posted on the web).

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: