关于MSNP开发中的命令参数

原创 2004年08月11日 23:25:00

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 explicitly requesting them, and do not contain transaction IDs. Finally, the PNG command and some SYN responses don't contain transaction IDs.

Newlines
Every 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 shouldn't be any problems unless MSN changes their server code.

Inside the payloads of payload commands, newlines are treated slightly differently. Their behaviour is discussed on the Payload Commands page.

Parameters
Parameters 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. The following command has one parameter:

<<< FLN example@passport.com/r/n

FLN is the command, example@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 noted above). 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 after the TrID. 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 immediately 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 don't repeat TrIDs, it doesn't 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 processor use and not increase your security at all.

Error Commands
An error is a special type of command sent by the server in response to a client command which it couldn't obey or couldn't 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 Syntax
The 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 Commands
Most 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 Commands
Asynchronous 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 just have the parameter immediately after the command code. Some of these commands are NLN, FLN, and BPR.

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 command 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 Order
Usually, 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 anything to happen.

OpenSips使用说明

OpenSips使用说明 安装MYSQL 安装及初始化下载地址:http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glib...
  • stSahana
  • stSahana
  • 2017年01月03日 09:17
  • 868

Maven命令行参数

Maven命令行参数参考: https://books.sonatype.com/mvnref-book/reference/running-sect-options.html查看mvn命令opti...
  • zwt0909
  • zwt0909
  • 2016年11月01日 14:15
  • 921

linux常用命令的各个参数

linux 基本命令 ls (list 显示当前目录下文件和目录 ls -l 详细显示 =ll ) [root@linux ~]# ls [-aAdfFhilRS] 目录名称 [root@lin...
  • mapeng892020
  • mapeng892020
  • 2017年01月06日 10:46
  • 1246

Ping 命令详解

简述: ICMP协议是“Internet Control Message Ptotocol”(因特网控制消息协议)的缩写。它是TCP/IP协议族的一个子协议,用于在IP主机、路由器之间传递控制消息。 ...
  • hebbely
  • hebbely
  • 2017年02月10日 13:28
  • 6949

FFmpeg参数中文详细解释和FFmpeg常用基本命令

FFmpeg参数中文详细解释 a) 通用选项 -L license -h 帮助 -fromats 显示可用的格式,编解码的,协议的... -f fmt 强迫采用格式fmt -I filename ...
  • DaveBobo
  • DaveBobo
  • 2016年04月11日 18:07
  • 2615

make 命令参数

在编译Android代码的时候,我们经常使用make命令,使用较多的是后面加上 -j 参数,开启多线程的编译,其实make还有很多参数的,使用make –help能够得到如下的信息。 用法:make ...
  • manjianchao
  • manjianchao
  • 2017年01月11日 16:26
  • 984

ffmpeg命令参数详解(二)

E:\program\myffmpeg\download\ffmpeg-20160803-d3426fb-win64-static\bin>ffmpeg.exe  -h  FFmpeg versi...
  • lbaihao
  • lbaihao
  • 2016年08月06日 21:35
  • 1169

MYSQL入门学习之十九:MYSQLDUMP命令参数详解

 mysqldump是mysql用于转存储数据库的实用程序。它主要产生一个SQL脚本,其中包含从头重新创建数据库所必需的命令CREATE TABLE INSERT等。对于导出的文件,可使用SOU...
  • yangshijin1988
  • yangshijin1988
  • 2014年07月29日 14:23
  • 1374

linux nc命令参数及用法详解--功能超级强大的网络工具netcat

功能说明:功能强大的网络工具 语  法:nc [-hlnruz][-g][-G][-i][-o][-p][-s][-v...][-w][主机名称][通信端口...] 参  数:   -G   设...
  • yjh314
  • yjh314
  • 2016年08月15日 11:13
  • 747

gcc 编译器常用的命令行参数一览

gcc是一个非常实用的Linux编译器,在实际使用中会经常用到。 1. gcc -E source_file.c -E,只执行到预编译。直接输出预编译结果。 2. gcc -S source...
  • k_wang_
  • k_wang_
  • 2015年12月26日 16:08
  • 2188
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:关于MSNP开发中的命令参数
举报原因:
原因补充:

(最多只允许输入30个字)