SuperSocket 1.6.4 Use summary one: basic understanding

Source: Internet
Author: User

SuperSocket is a lightweight and extensible Socket Development Framework, developed by Mr. Zhenyu, and is chosen because of a few of the exact compounding requirements:

    • Open source, based on the Apache 2.0 protocol, can be used for free to commercial projects.
    • High-performance event-driven communications.
    • Session-level Send queues allow you to send data concurrently through a session and maintain high performance and controllability.
    • Powerful and high-performance protocol resolution implementation tool simplifies the analysis of network data: with a variety of data frame filter, can realize their own data frame filter, can customize the data content protocol, sticky packet unpacking is a cloud.
    • Lightweight means that components are freely selectable and can be changed depending on the environment.

SuperSocket's architecture and design can be queried in the official Chinese document to Http://docs.supersocket.net/v1-6/zh-CN/Architecture-Diagrams

SuperSocket Workflow:

Each connected client is managed by the session, sending the data to the client also through the session's Send method, each client sends the data stream through the Receivefilter filter (here you can customize the protocol or use some of its own frame filter) To Reqestinfo,reqestinfo contains the data content, of course, if it is a custom protocol, you can implement your own reqestinfo, the contents of the packet directly loaded into the frame object.

The official documentation and demo also took a while to know how to use the function to achieve the project requirements, because the project is to do the data acquisition device TCP server, communication frame format is also a more common design, so probably a need to understand, the official documents and demo did not explain this piece in detail, But it also basically guides us how to do such a service program.

First, the simplest example of official documentation is the Telnet server.

Telnet example: The default appserver is designed to be a Telnet protocol, so the direct configuration-----start-up connection, disconnect, data receive event----logical processing, the simplest function is completed, You can understand it with the Windows self-signed Telnet debugging. At the same time learning SuperSocket also a point is to see the download of the SourceCode Quickstrat project, all kinds of scenes are involved.

Although SuperSocket is a cock bombing the framework of the day, but the default AppServer I believe still does not meet most people is the development scenario, I just want to use the most common TCP server function, send and receive data, manage the connection, or I want to implement a filter with the XXX protocol TCP server, I don't want to use Telnet at all. So, expanding appserver that's a must for homework.

In order to reduce the workload of the yard, there is time to bubble sister, the great SuperSocket is meticulous, comes with a variety of common frame filter, built-in common protocol implementation template as follows:

    • Terminatorreceivefilter   ( SuperSocket.SocketBase.Protocol.TerminatorReceiveFilter, Supersocket.socketbase)
    • countspliterreceivefilter   (SuperSocket.Facility.Protocol.CountSpliterReceiveFilter, supersocket.facility)
    • Fixedsizereceivefilter   (SuperSocket.Facility.Protocol.FixedSizeReceiveFilter, supersocket.facility)
    • Beginendmarkreceivefilter   (SuperSocket.Facility.Protocol.BeginEndMarkReceiveFilter, supersocket.facility)
    • Fixedheaderreceivefilter   (SuperSocket.Facility.Protocol.FixedHeaderReceiveFilter, supersocket.facility)

Use of the above templates can be found in the official documentation http://docs.supersocket.net/v1-6/zh-CN/The-Built-in-Common-Format-Protocol-Implementation-Templates

Here the first few templates may use is not complex, the use of the scene is relatively small, as for the use of Beginendmarkreceivefilter and fixedheaderreceivefilter is slightly complex, But they can basically meet the agreements used by the more commonly used industries.

The next one will do a demo use Fixedheaderreceivefilter to resolve the XX network acquisition equipment data information of the Protocol frame

This article by http://www.cnblogs.com/xiepeixing/original, reprint please famous source

SuperSocket 1.6.4 Use summary one: basic understanding

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.