Edited Question :
I decided to create an online chat for our site users and for get more details and experience , visit some chatrooms and compared them by yahoo online messenger. All chatrooms worked by Ajax ( call repeatedly to server even when wasn't new messages or any changes to display ) and had 4 second timeout between every call.
But yahoo online messenger connect to server just when it is needed and work faster than.
Thank you .
Wikipedia says that
YMSG is a proprietary protocol, a closed standard aligned only with the Yahoo! messaging service. Rival messaging services have their own protocols, some based on open standards, others proprietary, each effectively fulfilling the same role with different mechanics.
Also If you are interested in building some application then visit this official page. There are also some projects already done using different programming languages like C++, Java. For eg: libyahoo2, OpenYMSG
Here is an interesting study about different instant messaging protocols.