3

If creating an IM platform in Java, which would be a better way to implement communications between the clients and server? I was thinking either RMI or just a socket connection...

Advice please,

Thanks

Freddie
  • 1,687
  • 2
  • 16
  • 23

3 Answers3

7

I would use straight socket connection, using a well known protocol such as XMPP. You can use a library (like smack) to avoid implementing the whole protocol yourself.

The main advantage of XMPP over RMI or your self-made protocol is that is a well established protocol used for exactly that purpose: IM.

Some chat services already using XMPP include Google Chat (GTALK) and Facebook.

Pablo Santa Cruz
  • 170,119
  • 31
  • 233
  • 283
0

I already did this using Smack API, using XMPP protocol.

Topera
  • 11,829
  • 14
  • 65
  • 101
  • Related: http://stackoverflow.com/questions/177514/good-xmpp-java-libraries-for-server-side – Topera Aug 12 '10 at 19:26
0

CometD has been specifically designed for use cases such as Chatrooms. Differently from other protocols, it works over HTTP port 80, which means (nearly) no hassles with Firewalls.

Listen to a recent podcast with Greg Wilkins about the project, which goes into some details of issues with implementing Chatrooms and how it gets handled by CometD.

I believe there is a Java client for CometD if you need to have client on both sides of conversation (normally frontend is JavaScript).

Alexandre Rafalovitch
  • 9,629
  • 1
  • 22
  • 27