File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Chat Server Directory Service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Chat Server Directory Service" Watch "Chat Server Directory Service" New topic

Chat Server Directory Service

Nathan Heimdall

Joined: Mar 02, 2009
Posts: 20
Hi All,

I'm trying to implement a Chat Server Directory service.

I've created several Multi threaded Chat servers ( and clients) using sockets.

I want to have a Chat directory where the Chat servers can register as soon as they are available and once they shut down they are no longer listed in the directory.

The client can contact the directory service to request the list of servers and select which server to connect to.

So far I've implemented the server and client using sockets.

Any inputs on how to go about implementing the directory service?


"A single conversation with a wise man is better than ten years of study."
Rob Spoor

Joined: Oct 27, 2005
Posts: 20279

I'd use RMI. You will have one extra server, the directory service. This uses a UnicastRemoteObject subclass that implements your custom interface (which in turn extends Remote). Each chat server will become a client of this service.

An example on how the remote interface could look like:
This of course assumes that the ChatServer class is Serializable. It probably isn't (because of the sockets it uses), so you will need some little container class which does and holds the information on each chat server: name, host, port, etc. If you only need the host and port you could use InetSocketAddress for this.

Check out for more information on RMI. If you have any problems regarding RMI itself, you should visit our Distributed Java forum.

How To Ask Questions How To Answer Questions
Nathan Heimdall

Joined: Mar 02, 2009
Posts: 20
Will do, Thank you!
I agree. Here's the link:
subject: Chat Server Directory Service
It's not a secret anymore!