RRQMSocket is an integrated, ultra-lightweight network communication service framework. It has the characteristics of high concurrent connections, high concurrent processing, event subscription, plug-in extensions, multi-thread processing, memory pool, object pool, etc., allowing users to build a network framework more simply and quickly. In terms of transmission efficiency, synchronous transmission can reach 20w/s, and asynchronous transmission can reach 60w/s. The server's reception and processing efficiency depends on the number of threads.
Support environment:
.NET Framework 4.5 and above.
.NETCore3.1 and above.
.NETStandard2.0 and above.
Supported frameworks:
WPF
Winform
Blazor
Xamarin
Mono
Unity
Others (i.e. all C# systems)
Features:
1. Object pool
Object pools have many applications in RRQMSocket, the two most important ones being the connection object pool and the processing object pool. The connection object pool means that when the client successfully connects, it will first look for TcpSocketClient in the connection object pool, and then create it if it does not exist. If a client goes offline, its TcpSocketClient will be recycled. This is the reason for ID reuse.
Then there is the processing object pool. In RRQMSocket, the thread that receives data and the IOCP kernel thread are separated. That is, for example, the client sends 10,000 pieces of data to the server, but the server processes it very slowly after receiving it. Then the traditional iocp It will definitely slow down the receiving rate, then notify the client's TCP window that congestion occurs, and then let the client suspend sending. However, in RRQMSocket, all received data will be stored in the queue. First, it will not affect the reception of iocp. At the same time, threads will be allocated to process the received message information. This is equivalent to a "flood discharge lake", which can greatly Improve the ability to process data.
2. Multi-threading
Due to the existence of the processing object pool, multi-thread processing becomes simple. When the client connection is completed, the message processing logic thread of the client auxiliary class (TcpSocketClient) will be automatically assigned. If the number of server threads is 10, the first connected client will be assigned to thread 0, and the second Connections will be assigned to thread No. 1, and so on, in a circular manner. When a client receives data, it will queue the data into a queue owned by the current thread and wake up the thread for execution.
3. Traditional IOCP and RRQMSocket
The IOCP of RRQMSocket is also different from the traditional one. Taking Microsoft's official example as an example, MemoryBuffer is used to open up a memory, and then divide it equally, and then allocate an area for each session to receive the data. After receiving the data, make another copy, and then copy it. Data throwing processing. RRQMSocket takes an available memory block from the memory pool before each reception, and then uses it directly for reception. After receiving the data, it directly throws the memory block out, thus avoiding the copy operation, although it is only a small one. design, but when transmitting 64kb data 1000w times, the performance differs by 10 times. Therefore, based on this, the efficiency of file transfer will be high.
4. Data processing adapter
I believe everyone has used other Socket products, such as HPSocket, SuperSocket, etc., so the design of RRQMSocket also drew on the excellent design concepts of other products, and the data processing adapter is one of them, but what is different from the design of other products is that RRQMSocket The adapter function is more powerful. It can ignore the real data and simulate the desired data. For example, it can preprocess the data to solve the problem of data packetization. To solve the problem of sticky packets, you can also directly parse the HTTP protocol and return an HttpRequest object after processing by the adapter.
5. Sticky packages and subcontracting solutions
It is very simple to deal with TCP packet sticking and sub-packet problems in RRQMSocket. Just change the different data processing adapters. For example: to use fixed headers, you only need to assign instances of FixedHeaderDataHandlingAdapter to TcpSocketClient and TcpClient. The corresponding processor also has fixed length, termination character segmentation, etc.