Firefly Official Tutorial Netconnect using the documentation

Source: Internet
Author: User

1, distributed description
This module contains some processing methods of communication between server and client, including encapsulation of sending data, encapsulation of protocol header, subcontracting of TCP communication and processing of sticky packets.
2. Structure Analysis




Liberatefactory, the Protocol factory, the nature of all connections, the visualization of the service-side communication with the client, which contains three parts:
1) Liberateprotocol, the Communication protocol class, the connection establishment, the disconnection operation, sends the data and so on it to control
2) Datapackprotoc, the definition of packet protocol, all data parsing must abide by its custom rules
3) ConnectionManager, Connection Manager, all connections are under his command, you can find the connection in it, to operate
Connection, a Connection object with the client, through which he can communicate with the client, actively disconnect, actively push messages and so on.
3. Examples of Use
1) test_netconnect_server.py




2) test_netconnect_client.py




3) The above is the server (service side) and client (client) example, run the test_netconnect_server.py file, you will see that the server has started, and began to listen to 1000 this port.


4.jpg (37.3 KB, download times:)
Download Attachments [Url=] save to album [/URL]

[Color=rgb (153, 153, 153)!important] uploaded half an hour ago






Run the test_netconnect_client.py file within 5 seconds and you'll see it on the server side,




4) explained that, after the server runs, the client runs, the client builds two threads, each thread sends a message to the server, invokes the server's instruction number 111 method (that is, the echo_111 function), and prints "Hello". The server disconnects the connection ID 0 after 5 seconds after it is run and executes the Doconnectionlost method when disconnected.

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.