I have been using instant messengers like yahoo, gtalk, skype for more than 10 years but I still wonder what is the mechanism working behind it.
As per my understanding of a request on Internet, we send a request to server which returns us a response. That will explain how my messages are being sent to server. But what I don't get is how I receive a message from sender instantly.
One way I can think of is that my messenger keeps on checking with server after a fixed interval (say 5 seconds) for a new message (polling), but that sounds very expensive in terms of bandwidth.
The second way I can think of is that messenger somehow maintains a connection with server and receives the messages as they come to server. But in that case, isn't Internet supposed to work in a request-response mode?
Third way can be that server connects to the messenger and sends the message when it receives one. That too sounds unconvincing as how can server know location of messenger (IP address)?