Originally posted by rajesh karmani:
As i have heard its better to design a messenger based on RMI rather than writing a custom protocol using sockets or is it the other was round?
Can somebody clarify in that regard?
It kind of depends on exactly what you are trying to do.
Will both ends be using Java? Is there a specific type of message object that you can use to contain your message? Can you process the message through relatively few functions, such as receiveMessage, joinDiscussion, makeChatRoom?
If yes, these are things that would make me lean toward RMI.
Are you trying to interface with other network protocals such as AIM, Jabber, IRC? Are you writing a server which needs to be scalable and support hundreds or thousands of users? Do you want non Java clients to have access to your protocol? Do you want to tunnel your messages through a firewall?
If yes, these are things that would make me lean toward sockets.
If the protocol needs to be rich and complex, it is probably better to try and use something that already exists. Other choices besides RMI might be IRC,
SOAP, etc.
Designing a low level socket implementation of a complex protocol is kind of like designing your own B-Tree file system. You could do it, and it will probably be very efficient and fast when you get it finished. But if you re-use an existing higher level technology, your solution will be more adaptable to change.