Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

chat program??  RSS feed

 
nima lama
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!,
i am wondering which would be best to make chat program.
i know it can be made through java.net package, java.rmi package and javax.servlet package.
kindly tell me which would be best and reason me if possible.
thank you,
nima lama.
 
Omar IRAQI
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi nima,
In my opinion, the EASIEST way to do it is to use java.net + java.io package. And I don't see where servlets can help here.
If I were you, I would create a server that identifies at each moment who are the users that are connected (IP + nickname), and I would create a client app that interacts with the chater.
This client application would itsself contain a server part, and a client part. The server part will be a separate thread that is listening for other chaters to connect to this client app. So it would basically a ServerSocket with a well known port. And the client part of the client app, would be a Socket that connects to other chaters.
And at each moment, the client app is aware of the presence of all connected users thanks to the server application.
Now you will just need java.io.ObjectInputStream.writeObject("hello there"), to send data, and (String)java.io.ObjectInputStream.readObject() to get data. The ObjectIn/OutputStreams, you will get them from the Socket.getIN/OutputStream().
Regards.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!