aspose file tools*
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
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Chat Server Directory Service" Watch "Chat Server Directory Service" New topic
Author

Chat Server Directory Service

Nathan Heimdall
Greenhorn

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?

Thanks,

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

Joined: Oct 27, 2005
Posts: 19785
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Nathan Heimdall
Greenhorn

Joined: Mar 02, 2009
Posts: 20
Will do, Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Chat Server Directory Service