January 22nd, 2013, 02:19 PM
How do Instant Messengers work?
I would like to learn more about network programming. I have been thinking about how Instant Messengers work (ex: Live Messenger).
From what I read on the Internet I understand that when I start the client on my PC this will connect with a server somewhere on the net. Like this the server knows that I am on line. I guess the server or client can poll every 30seconds to see if I am still on line (not sure of this).
What I am finding hard to understand is what happens when someone wants to chat. The most simple model I can think of is that if John wants to chat with Ben then John sends his message to the server and the server (from some header information) forwards the message to Ben.
However this means that all messages have to go through the server, the server has to process every message to see who the recipient is. This I guess would work for a few clients. However not sure if it would work for millions of clients.
Or maybe the server exposes the information of a chat client with another chat client so that these can communicate directly together?
January 22nd, 2013, 05:33 PM
Both methods are possible, the first is easier to implement and generally more reliable. Skype uses a variation on the second method, most other networks use the first method as far as I know.
* The reason Skype uses a peer-to-peer based model is because the bandwidth requirements for voice and video are a lot higher than for text, so it's impractical to offer a free server-based solution for it.
Comments on this post