Monday, January 14, 2008

Simple Java Chat Client-Server

This is a project i had in the Computer Networks Cource in University.

Download it here

What was asked is to create a Java Chat Room application, which uses a certain protocol (given) to implement a server client functionality.



How the protocol works:


Client:

  • Client sends Login command. The server checks if no other person has that nickname and sends back the List command that is a list with all the other clients (explained bellow)
  • NewNick command. It is send by the server to the client to notify that nickname is not available.
  • PrivateRecieve , private message from nickname (!)
  • Logout: Client sends that command to logout from the server and then exists the Gui
  • Logout : nickname has logged out
  • Gui for all this, pretty simple

Server:

  • It opens port 9999 and wait some connection
  • When it get a connection waits for Login command. It then checks to see if nickname is available. If nickname is not available sends the NewNick command back to notify the client
  • If nick is availiable the server sends the List to all the clients
  • When it recieves a Post command then sends msg to all the users in the chat room
  • PrivatePost sends msg to the nickname
  • When recieves the Logout command, deletes the nickname from the clients list and resends the List command to everybody
  • Server is created with threads so that it can handle a large number of clients
Client Gui
  • Action - Connect Popups a window to select server, ip or host. If you run the server on your computer leave it to localhost
  • Action - Disconnect Disconects ...
  • When connected a second window popus to ask you for your nickname
  • If nickname exists the client asks you for a new one
  • When connected you can write your personal message down and press enter or the send button
  • For private message click on the nickname you want to sent it and write the message

The project is in fact simple and is based on the java tutorial http://java.sun.com/docs/books/tutorial/networking/sockets/index.html

The source code comments are in greek (since i am greek), but anything you might want to ask just leave a comment, i will answer as soon as i see it

Some images:








31 comments:

Anonymous said...

hi,,,thanx for this simple program,,,but i need a favor,,,can u explain to me how cThread class works?
im not that good in thread things,,,and another thing can u translate all comments into english,,,i'll be so thankfull,,,

Laza said...

Your comments cannot be translated by any online dictionary :( why is that?

Break Design said...

That's because it's Greeklish - Greek written in english. I will translate them when i have the time.

soorajb said...

hi, can u also posted the source code..

Break Design said...

The source code is included

Break Design said...
This comment has been removed by the author.
soorajb said...

hi again, am having problem to open the source code..
only the executatble file(.jar) is downloaded..
can u help me how to open the source code??
thx n advance..

Break Design said...

http://www.thecyprusguide.net/break_design/javachat.rar

It's not .jar it's a .rar file.

you can open it with WinRar http://rarlab.com/download.htm

Also jar it's the same think, basically a .zip file renamed.

Simply Complicated! said...

just wondering when will you be translating this Greeklish into english?

Admin said...

maybe never

Anonymous said...

Hi,iwouldto have the code translated,since am doing a similar project,only that with this 1 i have to include a message protocol for receiving and sending

Anonymous said...

Thanks for the code. I was just looking for a client gui. But try to stick with java conventions. Underscore is no go.

Anonymous said...

I can't connect to the server, it says Not Connected

Anonymous said...

Can you please tell me how should I use the code?

Saurabh Bhogal said...

hi thank nice program that help lost me.............

henry said...

i think is important you translate it to English or you use the normally Greek..so we can translate it for better understanding.thanks

henry said...
This comment has been removed by the author.
Isabel said...

Hello, this is great, you don't have to translate this, I think if people want to learn, they should figure it out themselves :) nice work

Anonymous said...

thanx bro...
nice job.

ritu said...

hi thanx 4 ur project wud u plzz tell me how can i run dis programm

Anonymous said...

Hi
this works awsome for me
i would have to make some tweaking to work the way i want it

and yes if the Greek is translated then stealing the credits would be easy
hats off to you :)

Anonymous said...

hi
can you chack the link...i think, the link is broken.when i try to donwload it gives error.
thanks

Anonymous said...

Hola

My question is? this program works in different computers

Styliana said...

geia!!! kanw kai egw ena paromio programma gia to panepistimio kai prospatho na kano allages sto programma sou gia na to fero sta metra mou. Mporeis na me voithiseis?? Vasika thelo na prostheso users ke na sindeontai sto diko mou server, parola afta den me afinei to programma sou na ala3w to localhost kai to server. Den doulevei xoris ta dika sou stixia!

Efxaristo! Pragmatika sozeis zoes :)

Anonymous said...

I'd like to thank you ! You helped me a lot :D

Anonymous said...

Hai this is great. but i can't connect. please help me :(

Anonymous said...

Can you tell what protocol is used??

Anonymous said...

I'm soory but I can't read the "Usage" at all. How do I reach the sever? Do I need the 192.XXX.XXX.XX or the 93.XXX.XXX.XXX address?

Anonymous said...

I'm soory but I can't read the "Usage" at all. How do I reach the sever? Do I need the 192.XXX.XXX.XX or the 93.XXX.XXX.XXX address?

kalid said...

hi,,Mr i am trying to run ur code,but GUI stay as Connecting...
where is the problem ?tnx

loreun jeny said...

Hello folks, would you say you are feeling tired or bore? We are giving you a stage in which you can invest your energy and diversion for your extra time. give taste to Meet New People, A chance to purchase and offer your companions, talk in private, chat in private, social game,dating, make companions on the web and play pets.