• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Chat Server Directory Service

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Sheriff
Posts: 22650
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Will do, Thank you!
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic