Introduction to XMPP protocol details

Source: Internet
Author: User

I introduced the implementation principles of the XMPP protocol. When I first learned programming, I used JAVA to implement the simplest version of IM communication, that is, the connection between two computers is established through the Socket, and I/O streams are sent for instant communication. Even though the IM software we use now looks very complicated, however, the basic principle is similar to the above, simply using the server <> client architecture, by logging on to the server to obtain personal information and friends, then, during the chat, you can directly use IP addresses and friends for instant messaging. XMPP protocol network architecture XMPP is a typical C/S architecture, instead of using P2P client-to-client architecture like most instant messaging software, that is, in most cases, when two clients communicate, their messages are transmitted through the server (for example, when two clients transmit files ). this architecture is mainly used to simplify the client and put most of the work on the server. In this way, the work of the client is relatively simple, and when a function is added, mostly on the server side. shows the Framework Structure of the XMPP service. XMPP defines three roles: XMPP client, XMPP server, and gateway. communication can take place between any two of the three. the server also provides routing functions for client information recording, connection management, and information. gateways are interconnected with heterogeneous instant messaging systems. heterogeneous systems can include SMS, MSN, and ICQ. the basic network mode is that a single client connects to a single server through TCP/IP, and then transmits XML on it. The working principle is: the node is connected to the server, and the server uses the certificate in the local directory system. Authenticate the target node. The Node specifies the target address to notify the server of the Target status. The server searches for, connects, and authenticates each other. The nodes interact with each other. The XMPP protocol is transmitted through XML files, and is not similar to QQ's point-to-point communication, but through the client to the server and then to the client, A simple XMPP communication process in the above process can be as follows: first, the client connects to the server, and the client sends an XML file through the IO stream, which contains its own user name and password. The server receives the XML file from the client and obtains the username and password for verification. If the verification succeeds, the server sends an XML file to the client, indicating that the client has successfully logged on. After successful login, the client can send an XML file to obtain the friend list. The server will upload the current user's friend to the client as an XML file. The client selects a friend and sends a message to it (in fact, it sends the message to the server, and the server forwards the message to the corresponding friend). The friend receives the message. Through the above process, this basic communication can be achieved. (For an implementation of XMPP Openfire + Smack + Spark) the following section describes some concepts of XMPP and describes the basic process of XMPP, the following describes some basic concepts in XML. An XMPP address is a node in the XMPP network structure. It has a unique identifier jabber identifier (JID), that is, the object address, used to represent a user, but it can also represent other content, such as a chat room. A valid JID includes a series of elements: (1) domain identifier; (2) node identifier; (3) Source (resource identifier ). the format is node @ domain/resource, node @ domain, similar to the address format of the email. domain is used to indicate the contacts of different devices or locations. This is optional. For example, if a registers a user on Server1 and the user name is doom, the JID of a is doom @ serverl, when sending a message, specify doom @ serverl. You do not need to specify resource. However, when a logs on to this Server, the JID of fl may be doom @ serverl, exodus (If a is logged on with the Exodus software), it may also be doom @ serverl/psi (if a is logged on with the psi software ). resources are only used to identify user locations or devices. A user can connect to the same XMPP server with multiple resources at the same time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.