We all use Gmail (Gtalk, now hangouts), FaceBook, SKYPE, Yahoo messenger, WatsApp and various other messaging tools on a daily basis. Many of us even use these IM clients  within our organisations for our official purposes. Even the notifications we receive on our android cells (GCM), make use of the same underlying technology.  So today just out of curiosity, I decided to take a step into this world of, ‘InstantMesagging (IM)’ and understand how this technology works to provide us with such an excellent way of communication.

So, here I present to you all, XMPP(eXtensible Messaging and Presence Protocol)! The backbone of today’s Instant Messaging world. [Google moving away from XMPP though].

So in this blog i will provide you all with an overview of XMPP. And in the future blogs series, we will implement a simple XMPP based server (ejabberd) and build our own chat application.

 

So Let’s Start from the Basics! What is XMPP?

Extensible Messaging and Presence Protocol (XMPP) is a protocol for streaming Extensible Markup Language (XML) elements in order to exchange structured data in close to real time between any two network endpoints.” Check out the official RFC for this Protocol.

In simple words, XMPP can be considered as a protocol for transporting small pieces of data between two places. These pieces of data are in a structured format ( XML ).

XMPP provides us with systems for building:

1. Publish-subscribe services

2. Multi-user chat

3. Form retrieval and processing

4. Service discovery

5. Real-time data transfer

6.Privacy control

7. Remote procedure calls

 

Stanzas – The Building Blocks

Lets take a look at the structure XMPP uses. XMPP mainly consists of streams. Structured data is sent between the  network endpoints using these streams.  These streams are established both ways( between the server and the client.). So for a single connection between a server and a client, two streams are established The structures data that I am referring to in the above sentences, in the  XMPP language are referred to as Stanzas. All the communication features, like whether a user is online or not, chatting, group chats, a user’s status (available, away, for eg. your status on WatsApp)  that XMPP servers provide are through the exchange of these Stanzas.

 Stanzas are of three types:

1. Presence

2. Message

3. IQ

 

Is the Other Guy Online? The Presence Stanza Tells You: