File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes IM Chat Client/Server flow? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "IM Chat Client/Server flow?" Watch "IM Chat Client/Server flow?" New topic

IM Chat Client/Server flow?

Rob Poulos
Ranch Hand

Joined: Aug 21, 2009
Posts: 49
hopefully this is the right forum for this

I am currently working on an instant messaging chat application and was wondering how the flow of communication should go between Client A and Client B

My initial thought was to have Client A & B connect to Server A and pull down the connection information (IP's, Ports, etc..) for their "buddies". at this point Clients A & B would be able to iniitiate a direct connection between themselves, leaving Server A out of it. Server A would periodically broadcast changed data to clients but thats about it. It would be the clients responsibility to manage its connections (chat sessions). Might run into some difficulties doing this with firewalls, routers, etc...

or... all communication between Clients A & B must pass through Server A before that communication is passed on to Client B, making Server A the manager of all connections (chat sessions). This is definitly more overhead for the Server and more hops means more points of failure. But, this drasticaly reduces the potential issue stemming from Firewall/router issues.

your thoughts?

SCJA, ITIL V3 Foudation, Studying for SCJP6
Joe Ess

Joined: Oct 29, 2001
Posts: 9191

Your "initial thought" is a common "peer-to-peer" networking scheme. Your second thought is a typical "client-server" scheme. They're both valid ways to implement a network application.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: IM Chat Client/Server flow?
It's not a secret anymore!