Home arrow HTML arrow Page 4 - The MSN Messenger Protocol Torn Apart: Part 1/3

The MSN Messenger Protocol Torn Apart: Part 1/3

Ever wanted to build your own MSN messenger? In this article series Neville rips apart the MSN messenger protocol for all to see. It's a must read for any developer!

Author Info:
By: Neville Mehta
Rating: 5 stars5 stars5 stars5 stars5 stars / 93
October 20, 2002
  1. · The MSN Messenger Protocol Torn Apart: Part 1/3
  2. · Digging Into the Protocol
  3. · The Workings of the Protocol
  4. · Change Your Initial Status
  5. · Order the List
  6. · User Statuses
  7. · Conclusion

print this article

The MSN Messenger Protocol Torn Apart: Part 1/3 - Change Your Initial Status
(Page 4 of 7 )

After we are authenticated, the first thing we do is to change our current status. We have a command called CHG. This command helps us to change our current status. This is what we sent to the server to change our initial status:


We have the command identifier CHG. We have the unique transaction id. We also have a parameter called "NLN". NLN tells the server to change our status to online. Like NLN, we have various parameters for other statuses. For example this would be the command we would send the server if we wanted to change our status to Hidden or Invisible:


Yes, HDN is the parameter we send to tell the server to change our status to Hidden/Invisible. There is a list of these parameters and what each one does in Microsoft's official draft on the protocol. I have attached the same at the end of this article.

The server then sends us back this reply confirming the status change:


The reply consists of the command identifier, the transaction id and the current status of the user.

Retrieval of a Few Important Server Messages
By now, the client should be ready for a few messages from the server. What are these messages? Well, we could regard them as commands sent to us by the server but commands having a different format. We have seen the standard command format, which looks like this:


The message command doesn't in anyway look like this. If we see one such message we would be able to understand the format. As soon as we notify the server of our initial status, the server sends us this message command:

MSG Hotmail Hotmail 450
MIME-Version: 1.0
Content-Type: text/x-msmsgsprofile; charset=UTF-8
LoginTime: 1034601891
EmailEnabled: 1
MemberIdHigh: 93760
MemberIdLow: -52562410
lang_preference: 1033
preferredEmail: neville2150895@hotmail.com
country: IN
Gender: m
Kid: 0
Age: 19
BDayPre: 2
Birthday: 30245
Wallet: 0
Flags: 1031
sid: 507
kv: 4
MSPAuth: 4voZp65RUDJlf6KzMhWAgJKts*N3Wn8OVQB6AW

This is what the command looks like. We first have MSG, which is the command identifier. The next two parameters, say Hotmail and Hotmail and finally the number 450. The number 450 denotes the total number of bytes in the entire message excluding the current line (The line which has MSG in it, the first line).

Next, we have the mime version and content-type. The mime version would be same in all cases but the mime content-type is "text/x-msmsgsprofile" in this case. The char set of the message is mentioned in the same line thereafter. All the lines after that consist of the mime body.

This message, which the server sent us contains details about the .NET passport we signed into. The body of this message thus contains details of the user signed in like age, gender, birthday, postal code etc.

Another such message we should be ready to except is the following one:

MSG Hotmail Hotmail 221
MIME-Version: 1.0
Content-Type: text/x-msmsgsinitialemailnotification; charset=UTF-8

Inbox-Unread: 0
Folders-Unread: 2
Inbox-URL: /cgi-bin/HoTMaiL
Folders-URL: /cgi-bin/folders
Post-URL: http://www.hotmail.com

Again, like all other message commands, this one consists of the command identifier, the two Hotmail parameters and the total number of bytes on the first line. Next we have a mime version, which is the same in all messages and the Content-Type, which is "text/x-msmsgsinitialemailnotification" in this case. We also have the char set on the same line thereafter.

This message contains details about email in the inbox of the user. You must have noticed when you login into your messenger account and you have any new unread mails you are prompted. Well this is the message responsible for that prompt. You see the string Inbox-Unread :0 in the mime body. That shows there are 0 unread mails in your inbox. This message also has a few other details about your inbox.

Again, these are messages that your client may or may not want to respond to. I have just included these in this article to let you know about the entire process in detail. In your version of msn messenger itís entirely up to you to prompt the user about new mail. In this case if you donít want your messenger to care about new unread mails in your inbox then you could ignore these messages. The first message sent to us by the server, which has the users .NET passport details passed through, is quite useless.
blog comments powered by Disqus

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials