This page uses CSS styles

Project work within a PJW course on CTU FEL, Prague

i784 - Distributed chat with file transfer

Oto Válek

CTU FEL Prague, summer term 2001/2002, classes on Thursday 9:15 am

1. Summary

This is a stand-alone java application, implementing a simple distributed chat. Therefore, no central server is needed for user communication. However, a server may be used for initial establishing a connection. Both graphic (AWT) and console interface is available.

Chat on Windows

2. User commands

User commands can always be entered on the console input. Graphic version lets you use buttons and dialogs instead. The commands are case-insensitive. The list of them follows:

SETUP Alice 222.222.222.222 6060
SETUP Bob pc58.lab.ksu.edu 6060
Sets your own nickname, IP-address and port. Application starts to listen on specified port for incoming connections; Use this command prior to CONNECT nebo ROOM commands. A Setup button invokes this command.
CONNECT 222.222.222.222 6060
CONNECT pc58.lab.ksu.edu 6060
Connect to the network via one of its members. Application will get nicknames and adresses of other users from this user. Then it transmits your own contact information to all of them. A Connect button invokes this command.
ROOM http://server.com/chat.cgi Users Connect to the network via a central server. Enter a name of the room, which has to be the same as the room of the others. A Connect button invokes this command.
FILE C:\Documents\homework.rtf
FILE ~/homework.rtf
Send a binary file to all users. Received files will be stored in the current directory. Size of the file being sent is limited.
DISCONNECT Disconnect from the network. The application still keeps listening for new incoming connections. A Disconnect button invokes this command.
EXIT Disconnect from the network and close the application.
Hi, Alice A command which does not begin with these keywords is sent to all the users as a text message.
Chat on Solaris

3. Running the application and command-line options

The application is stored in JAR archive. To run it on your system, use
java -jar Chat.jar
When you need Java to free the console, use following commands:
java -jar Chat.jar & (Unix,Linux)
start /b java -jar Chat.jar (Win NT)
Command-line options:
-text invokes console version
-nick Alice
set yout nickname (as SETUP command does). Host and port are set to defaults.
-setup Alice 222.222.222.222 6060
set your identity (as SETUP command does).
-room http://server.com/chat.cgi Users
connect to network (as ROOM command does).

4. Communication protocol

Communication protocol is character and line based, like many othes TCP using protocols (HTTP, TCP). Every command is handled in separate TCP connection and is followed by newline character. Unless otherwise noted, command reception is acknowledged by OK response followed by newline character. A list of commands follows:
GET Request for the user list. Command is sent by a new member before the CONNECT command. Host responds with the list of ITEM <nick> <host> <port> lines terminated by the OK line.
CONNECT <nick> <host> <port> Connection to the network. A new member sends this message to users acquired with GET command and anounces its identification. Others will add the new user to their user lists.
MESSAGE <nick> <host> <port> <text> A text message. A sender sends it to all the users, including himself. If the receiver doesn't know the sender, he stores him to his user list.
FILE <nick> <host> <port> <name> <size> A binary file. A sender sends it to all the users, excluding himself. If the receiver doesn't know the sender, he stores him to his user list. File data follow the command line in BASE64 encoding.
DISCONNECT <nick> Disconnection from the network. A sender sends it to all the users, excluding himself.

5. Files