This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Chat Server Directory Service

 
Nathan Heimdall
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks,
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 http://java.sun.com/docs/books/tutorial/rmi/index.html for more information on RMI. If you have any problems regarding RMI itself, you should visit our Distributed Java forum.
 
Nathan Heimdall
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will do, Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic