Connection instructions on the MSNP protocol

xiaoxiao2021-03-06  174

Connections OverviewAll connections to MSN servers take place over TCP / IP. The client always makes the outgoing connections to the servers. The official port for MSN Messenger is 1863, although there are many places in the protocol where alternate ports could be specified, so this May Beject to change.

The connection to the server must be considered asynchronous - you can send many commands to the server without waiting for a reply, and the server will not necessarily reply to your commands in the order you sent them The server may also send messages that are. NOT IN Reply, WHEN Logging In.

There are also several OOB (out-of-band) protocols that take place directly between clients and do not involve the server. These protocols are described in their respective sections, and are not necessary for basic functionality of a client.

EncodingAt the lowest level, computers can only send 1s and 0s to each other. In order for two computers to communicate, they must agree on what the 1s and 0s represent. In MSN Messenger (except in file transfer), they represent characters, such AS "Latin Capital Letter A", "Digital Four", or "Runic Letter Short-Twig-Sol". in Other Words, MSN Messenger Is A Text-based protocol.

NOTE: How these Characters Become Squiggles On A Computer Screen Is Another Matter Entirely.

In theoryThere are many different standards for representing characters using series of 1s and 0s. ASCII (the American Standard Code for Information Interchange) is the most famous and most widely used. It says that every byte with a decimal value between 0 and 127 inclusive represents a character -. for example, a byte with value 90 represents "Roman capital letter Z", and a byte with a value 32 represents "Space" ASCII says nothing about what to do with bytes whose value is greater than 127. The complete ASCII table can be found many places on-line, including www.asciitable.com.Because ASCII was primarily designed for use in America, people in other parts of the world have defined other standards - mostly, these are just extensions of ASCII to use bytes With Values ​​Higher Than 127, But Some Languages ​​Are So Unlike English (Eg Japanese) That They've Started over from Scratch.

One popular standard is ISO 8859-1, which extends ASCII to make it more useful in Western Europe - for example, it says that a byte with value 163 represents the British currency symbol (£), and a byte with a value 226 represents " Latin Small Letter A with circumflex "(â)

A more ambitious standard - which is on course to eventually replace ASCII - is Unicode, a single standard that can represent every character used in every language in the world, including quite a few ancient languages ​​It seems the world is enough, though, as. The Decided Against Klingon Language Support.

Unfortunately, the increased ambition of Unicode must translate to increased complexity - most importantly, no direct translation of bytes to characters can possibly please everybody Instead, every character is represented by a "Unicode value", and that value is represented by one or more. Bytes Using a "Unicode Transformation Format", Such AS UTF-8 or UTF-16.THE MOPULAR FORMAT IS UTF-8, Which Was Designed to Be Compatible with Ascii. Like ISO 8859-1, IT Adds Meanings for BYTES with VALUES Greater Than 127. There is overfelion unicode Values, And Only 256 Values ​​Can Be Stored In A Single Byte, So Unlike ISO 8859-1, UTF-8 May Up to Six Bytes To Repesent One Character.

In PracticeData sent to and from MSN servers is encoded as UTF-8, an ASCII-compatible multi-lingual format that represents non-ASCII characters as sequences of two or more bytes. You need only worry about the difference between UTF-8 and ASCII IF Your Program Will Need to Print Multi-Lingual Characters On-Screen, In Which Case You Should Find Out WHether Your Programming Environment Supports Unicode (And if So, How Well).

If you send or receive plaintext MSGs without a charset = UTF-8 parameter, you should assume the message is sent in ISO 8859-1, an ASCII-compatible format for use in Western Europe that represents non-ASCII characters as single bytes. If you specifying a character set other than UTF-8 (eg charset = KOI8-R), the official client will just ignore your message. The official client always includes charset = UTF-8 in messages it sends, and so should you.

URL-encodingAt many occasions in the protocol, text may need to be URL-encoded (also referred to as URL quoted). Nicknames, display names, group names, and phone numbers are all examples of things that must be URL-encoded. URL -encoding is used to make sure a particular parameter does not contain any spaces, newlines, or otherwise invalid characters.URL-encoding is defined in section 2.2 of RFC 1738. Basically, it replaces every special character with a percent symbol followed by the two digit hexadecimal representation of the character. For example, a space becomes% 20, a percent symbol becomes% 25, ​​a linefeed becomes% 0A, and a carriage return becomes a% 0D. You can find a list of hexadecimal ASCII values ​​at asciitable. COM.

WHERE URL-Encoding Applies, The RFC Says That Everything Except Numbers, Letters, And The Special Characters $ -_. ! * '(),; /?: @ = & Should Be URL-Encoded. In Practice, you need online Encode Those Characters Whose Hexadecimal Value IS 20 Or Below (IE Space and Below), and the "%" Character, Which Has A Hexadecimal Value of 25. However, You May Encode Any Other CHARACTER IF you wish.

Because The Official Client Decodes Every Character, AND NOT JUST Required Ones (Like% 25 and% 20), Other Clients Must Decode Every Character.

IF you real want to url-encode multi-byte UTF-8 Characters, You Should Do It One Byte At A Time, So The UTF-8 Character with Hexadecimal Value D786 Would Be Reperesented AS "% D7% 86", Not "% D786 ". And Therefore, When Decoding Strings, First Url-Decode It, And Then Convert It To UTF-8.

XML-encodingXML is the "eXtensible Markup Language", a bit like a generalised version of HTML. XML is used at a few points in MSN Messenger. In XML-encoded text, & must be converted to &. Whereas URL-encoding replaces special Characters with "% nn" (where "nn" is the hexadecimal value of the character), XML-Encoding Replaces the with "& # xn;". The official client considers ~ ^ = [{] / |;:? As Special , but the server does not require this.Order of CommandsData sent to and from the server are divided into commands as explained in the Commands page. The server and client can send multiple commands in a packet, or spread out one command over multiple packets Writing a client That Parses Data by Packets Is Not a Good Method.

All normal commands end with a newline. Special types of commands specify the length of the body in bytes. When writing functions to parse commands, you will need to separate commands by newlines, except when receiving special commands with specified lengths.

HTTP ConnectionsIn order to use MSN in some highly restrictive environments, it is possible to wrap up an MSN Messenger session in HTTP requests and responses. This is slow and wasteful of bandwidth, so end-users should be discouraged from using it when normal connections are Possible. this Type of Connection is Explained in The HTTP Connections

ProxiesA proxy server is a program which takes messages from one side of a connection, processes them, and may or may not forward them to the destination. Proxies can be used to reduce bandwidth (eg by providing a local cache for web pages), increase security (eg by requiring a username and password before allowing connections), or any number of other reasons.A good proxy server should be invisible (or almost invisible) to the destination server, so you are free to support whichever proxy servers you like. The Official Client Supports Socks Versions 4 and 5 Proxies for Use with Normal Connections, and http proxies for use with http connections.

SOCKSSOCKS (which just stands for SOCKetS) is a very mature protocol, designed for use by general-purpose proxy servers on networks that want to control access to the public Internet. Unlike most applications protocols, which are used for some particular purpose (eg MSN Messenger is buy for instant messaging, socks is just buy to tunnel connections.

SOCKS version 4 is specified at http://archive.socks.permeo.com/protocol/socks4.protocol, the version 4a extension is specified at http://archive.socks.permeo.com/protocol/socks4a.protocol, and version 5 is specified at RFC 1928. SOCKS4 only supports TCP connections, but SOCKS5 adds support for UDP, ICMP, and other less widely used transport protocols. You should be able to find a SOCKS library for your chosen operating system and programming language. If Not, You'll Have to Write It Yourself Based on The Protocol Specifications, Above.

HTTP ProxiesIf you're wrapping MSN in an HTTP connection, you can use an HTTP proxy. HTTP version 1.1 (defined in RFC 2616), was designed with proxy servers in mind. All HTTP requests must include the complete URL of the resource being requested , so using an HTTP proxy server normally just means opening a connection to your proxy server instead of the server you really want to contact - the proxy server will detect where your request is supposed to go based on the URL.Some HTTP proxy servers may require You to include Special Headers - for Example, To Authenticate Yourself with the proxy server. RFC 2616 Defines The official client.

转载请注明原文地址:https://www.9cbs.com/read-128215.html

New Post(0)