Messaging system in real time ??

Messaging system in real time ??

I'm trying to make a messaging system like "Whatsapp", "Line", "WeChat" etc etc ... In jQuery Moobile, I have understood that I use sockets, but need some guidance, because this is new to me.

The system only has one on one conversations. No group conversations. You will also have state changes.
I have already run the chat, sending messages and everything, just need to be real time .. Can anyone help?

I should use?