Monday, July 26, 2004

Chat server and client in Java

Over the weekend I wrote a chat server and client.
It is essentially xml over http.
No auth , no message timeouts - just a very simple server : essentially an implict trust is assumed.
Ofcourse , the code is been given out - so you can change it !
The server needs to be hosted publically - so that clients (which can be behind a firewall) can connect to the server (direct or via a http proxy : both supported).

The necessity was that one of my friends was not able to chat with his girl friend 'cos her company was blocking all popular chat servers.
He has direct net conn (with a dhcp public ip) , while she goes through the company proxy to reach the web.
Essentially this is currently a one-off solution for his requirement :)

When he mentioned his problem , it got me thinking on how it is so easy to deny service to users without disrupting their normal net access.
Admin just needs to block a particular host (and its various ip's) and port and voila ! that service gets disabled (in this case chat).
It is this predictability of the server that enables this kind of behaviour - same for napster , kazaa , and the like.
Hence need of the hour is some kind of distributed server without a visibly evident server-set (which can get blocked) 
Last week (same day friend told me of this) , I had discussion of such a generic peer-to-peer communication protocol with Alok over lunch.
After that lunch , got into a discussion with Rajesh and Noble  and we came up with a basic idea and design of how such a fault tolerent distributed network would be , how to manage the various aspects of it , etc.

Both of them consider that this is quiet a normal engineering solution to a given problem - but I feel that this can be extended to domains that are not just restricted to basic user communication (example - gnutella protocol becomes a small subset of this from what i understand of gnutella).
Right now , the idea is to create such a fault tolerent , distributed server-set to which arbitrary clients can connect to and make a reference implementation for chat using the code I will be putting out .... Note - I am good at dreaming :) So none of this might bear fruit !

I will be putting up a link to the code ...  Have not written a build.xml (lazy me :) ) - was relying on the IDE to take care of building ... ofcourse this is not a proper solution when I plan to give out the source !
Will be adding a build.xml and then releasing the code ... tommorrow (I am bad at build scripts ... so will need someone-else help - must bug Noble :) ) !

Note : the XmlWriter in the source tree does not take care of encoding the xml data properly - hence any xml tag like messages will make the server break and reject that message :) - ofcourse , this will be fixed in a later release - not tommorrow's one though ...

--------------


Removed the xml limitations mentioned above :
The source is available here : http://www.geocities.com/mridulm80/chat.html
Have fun !! And please feel free to give feedback

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home