SuperSocket basics 1: SuperSocket Basics
SuperSocket BASICS (I) ------ Basic Concepts
The TCP socket service framework has been used in the project before, but it is not conducive to expansion. I recently got started with the open-source superSocket. It feels very good. Let's record it. Official Open Source Address: http://www.supersocket.net/
Basic concepts:
SuperSocket:Is a scalable open-source Socket framework. It is a lightweight, cross-platform and scalable. Net/Mono Socket server program framework. You can easily use SuperSocket to develop a Socket service software.
Features:
1. High-performance event-driven communication.
2. Easy to use. You can create several classes to obtain a robust Socket server.
3. the built-in command protocol allows you to quickly create a network command line interface server.
4. Powerful performance protocol parsing implementation tools simplify network data analysis.
5. flexible configuration and friendly API.
6. Multiple listeners are supported, allowing a server instance to listen to multiple clients.
7. multi-server instance hosting supports complex deployment requirements.
8. application domain and process-level isolation can meet most host scenarios.
9. built-in SSL/TLS encryption support.
10. Session-level sending queues can send data through sessions and maintain high performance and controllability.
11. The SuperSocket command processing mode makes your business logic clearer and more regulated.
12. Excellent scalable API support: Command Filter, Connection Filter, and Command Loader;
13. The replaceable log framework can satisfy your favorite log components.
14. Support for dynamic languages, allowing Python and other scripting languages to implement commands.
15. Compatibility with Mono/Linux at the binary level.
Architecture Design:
Level:
Level Analysis:
SuperSocket level
I. device layer: the Policy Server Based on flash and SilverLight and the Protocol implementation based on the receiving filter.
2. Application Layer: Scalable Application Services, including API integration. Session container and command framework.
3. Socket Layer: the socket service is driven by TCP and UDP events.
SuperSocket Object Model
Model Analysis:
1. The application service AppServer includes the Command Commands and Session container Session contaioner.
2. Object level: basic configuration Config-> Command filter Command Filters-> Log and Log factory Log/LogFactory-> Command loader CommandLoaders-> receive Filter Factory ReceiveFilterFactory-> Connection filter Connection Filters.
3. Socket service: Multi-client listener, TCP1, TCP2 ,.... UDP.
SuperSocket Request Processing Model
Model Analysis:
1. After the client establishes a connection with the Socket Listener of the Server, the SuperSocket Service regards the connection as a Session. Indicates a logical connection between the client and the server. Data Transmission and receiving are all processed in this Session (the data stream in this process is binary data ).
2. Sessions carrying data streams pass the filtered data to the RequestInfo object through the default or custom accept filter. Each client object has to instantiate a RequestInfo class and replace the received binary flow with the requested instance. The detailed concepts will be summarized below.
3. Execute the Command according to RequestInfo. A Command contains a Session and RequestInfo, and parses the data in the Command as needed. You can also send data to the client through Session. For example, some DTU or RTU devices need to send instructions to return data.
The request processing model can summarize the basic development process:
1. instantiate the AppServer object and listen to the client session at any time.
2. Define the RequestInfo object type to receive and process binary response streams.
3. Define the data receiving filter and ReceiveFilter to receive filtered data and assign the data to the RequestInfo object type.
4. inherit from the appServer constructor to use the RequestFilterFactory for receiving and filtering, and execute the custom ReceiveFilter and RequestInfo.
5. parse and use the data in the RequestInfo object in the data request delegate event of 1.
Next, we will take the official instance as an example to summarize