What are commands? Everything sent between the client and the server is in the form of a command. Commands are represented with a three letter, all-caps, command code. All normal commands have a transaction ID (explained below) and end with a NEWLINE (Also Explained Below). Commands Sent by The Client Will Generally Cause The Server To Respond with One or more Commands.
There are four special types of commands which behave slightly differently than normal commands. Payload Commands span over multiple lines. Error commands have numbers instead of letters in their command code. Asynchronous commands are sent by the server without the client requesting them explicitly, and do NOT Contain Transaction Ids. Finally, The PNG Command and Some Syn Res. Don't Contain Transaction IDs.
NewlinesEvery normal command ends with a newline (see the Payload Commands page for exceptions). The use of / r and / n throughout this document are explained here. The official client always ends commands with / r / n and the server always ends commands with / r / n. it is recommended That You do this TOO.
However, the server will accept commands ending with just / n, but not just / r. If you are looking to save as much bandwidth as possible, go ahead and use / n, and there should not be any problems unless MSN changes their Server code.
Inside the payloads of payload commands, newlines are what. Their behaviour is discussed on the payload commands page.
ParametersParameters exist to provide additional information with each command. Most commands have at least one parameter. Each parameter is separated by a space. Some commands also have a transaction ID immediately after the command and before the parameters. For the purposes of this documentation, the Trid Does Not Count As a parameter: <<< fln example @pastract.com/r/n
Fln is the command, esample@passport.com is the parameter, and / r / n is the newline.
It is possible to send certain commands with multiple spaces between parameters, tabs instead of spaces, tabs mixed with spaces, and trailing spaces and tabs. This has not been thoroughly tested. In any case, the server always sends one space in between parameters and No Trailing Whitespace (with The Exception of The Standard NewLines).
Transaction IDs (TrIDs) Transaction IDs, abbreviated as TrIDs, are used to match a client command with a server response. Commands sent by the client are required to contain a TrID, and commands from the server sent in direct response to that command will contain The Same Trid (with the exceptions note). in Most Cases, There Will Be Just One Response To Each Client Command.
Every TrID is a number between 0 and 4294967295 (2 to the power 32, minus 1). Even though completely legal, it is advisable not to use 0 as a TrID because some asynchronous commands use 0 as the TrID and it may cause confusion. The TrID always comes right after the three letter (or three digit, in the case of errors) command code, and they are separated by a space. If the command has parameters, the parameters will follow the TrID and they will be separated by another Space. OtherWise, There Will Be No Space Af. Below Is An Example of Sending The Ver Command With A Trid of 15 And Receiving The Response from The Server. >>> VER 15 MSNP8 Foo CVR0 BAR / R / N
<<< Ver 15 MSNP8 CVR0 / R / N
The server does not make any changes based on your TrID; it only responds using the same TrID you sent it If your TrID is greater than 4294967295, the server will behave unpredictably If you send a TrID that is not a positive integer, the.. Server Will Immedierately Disconnect You. If You Repeat The Same Trid in Multiple Commands, The Server Will Not do Anything Differently, But It Will Be More Difficult For The Client To Track Responses.
The official client always increments the TrID by one after sending each command. As long as you stay in the correct range and do not repeat TrIDs, it does not make much of a difference. Keeping the number low will save a small amount of Bandwidth - Probably Not More Than 5% of Your Total Bandwidth for the session. Using Random Numbers Will Increase Your Security At All.
Error CommandsAn error is a special type of command sent by the server in response to a client command which it could not obey or could not understand. Errors follow all of the normal rules of commands, except that the three-character command codes are always three-digit numbers. A detailed list of errors can be found in the error List page.If something goes wrong, an error will be sent in place of the expected command. For example, if a client sends an ADD command, it should Normally Receive Another Add Command Back from The Server. However, IF The Client Specifies A Nonexistent Account Name As A Parameter, The Server Will Respond with error 201 INSTEAD OF THE ADD COMMAND.
Clients Never Send Error Codes to the Server. The Server Never Sends Error Codes That Aren't in response To any particular client command.
Error SyntaxThe syntax of an error command is very simple. The command code is just a three digit number, and it specifies the TrID of the client command it is in response to. There are no additional parameters.
However, according to the original IETF draft, errors can be sent with additional parameters. I have never seen anything like that sent, but just in case, every client should be prepared to receive parameters without crashing.
Payload CommandsMost messages are just one line of data, ending with a newline. Payload commands have a chunk of data following the newline. The length of this data (in bytes) is specified in the last parameter of the command. The payload commands in MSNP8 Are QRY, PAG, NOT AND (MOST Importantly) msg. Here is an example of a payload command:
>>> QRY 1049 msmsgs@msnmsgr.com 32 / R / N 8F2F5A91B72102CD28355E9FC9000D6E (NO NEWLINE)
See the payload commands page for more details.Asynchronous CommandsAsynchronous commands are commands sent by the server, but not in response to any command sent by the client. Because of their nature, they have no assigned TrID. Some asynchronous commands have no TrID, and .
Other asynchronous commands always have a TrID of zero. Some of these commands are ADD and REM. The reason that these commands still have TrIDs is because they are also used as a client command with a server response. Only in special cases, like where a Principal is added to the reverse list, does the server send the commnd as an asynchronous command with a trid of zero.
Asynchronous Commands Can Be Sent At Any Legal Place In The Protocol - Even Between A Block of Related Replies Such as in Between Two Ilns.
Command OrderUsually, replies to commands will come in the order that you sent the commands. But this is not always the case. Sometimes, you may send commands in the order of 1, 2, 3, and the server will respond to them in the ORDER OF 2, 3, 1. This is why trids are very useful.
Some Commands Have Multiple Responses from The Server. These Responses Contain The Same Trid As The Original Command (Except Syn Responses). A Command That Can Have Multiple Responses Is CHG.
Unfortunately, there are no real rules on the order of unrelated commands. For example, a client can receive an ILN in the middle of a list of BPRs. If you examine the server behaviour enough, you can start to make rules, but Microsoft often Changes The Server Implementation and You Would Have To Start All Over. It's Best for a Client To Just Expect Anyhes to Happen.