Unlock instant, AI-driven research and patent intelligence for your innovation.

Communication method and system based on multiple query threads

A communication method and technology of a communication system, applied in transmission systems, database management systems, digital data information retrieval, etc., can solve the problems of increasing the time consumed by switching systems and consuming thread performance, so as to reduce the time consumed and improve concurrency Processing speed, speed-enhancing effects

Active Publication Date: 2019-06-18
FUJIAN TIANQUAN EDUCATION TECH LTD
View PDF5 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

However, this solution uses multiple threads to receive connection requests, which increases the time consumed by the thread switching system, and uses the same thread to monitor sockets, accept connections, and query, which will consume thread performance.

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Communication method and system based on multiple query threads
  • Communication method and system based on multiple query threads
  • Communication method and system based on multiple query threads

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0083] Please refer to figure 2 , Embodiment 1 of the present invention is: a communication method based on multi-query threads, comprising the following steps:

[0084] S1: Create a listening socket, and bind it to the IP address of the server (such as 0.0.0.0) and an available port of the server (such as port 80); after binding, the server passes through the listening socket The word listens for client connections.

[0085] S2: Create more than two query threads, more than two data processing threads, one accepting connection thread and more than two data sending threads; among them, the specific number of query threads, data processing threads and data sending threads depends on the data throughput Capacity determination; preferably, the ratio of the number of query threads, data processing threads and data sending threads is 1:1:1, which can avoid waste of thread resources.

[0086] S3: The connection accepting thread accepts the connection of the client through the lis...

Embodiment 2

[0095] Please refer to image 3 , this embodiment is a further expansion of step S3 in Embodiment 1, specifically including the following steps:

[0096] S31: preset the duration of the time slice.

[0097] S32: The connection accepting thread accepts the connection of the client within a time slice through the listening socket, returns the connection socket corresponding to each client one by one, and stores it in the accepting socket queue.

[0098] S33: Distribute the connection sockets in the accepting socket queue to a query thread with the least number of current connection sockets.

[0099] S34: Determine whether there are more than two query threads, if yes, perform step S35, if not, directly distribute to the query thread with the least number of currently connected sockets.

[0100] S35: Distribute the connection sockets in the accepting socket queue to any one of the query threads.

[0101] S36: Clear the accepting socket queue; then the accepting thread continue...

Embodiment 3

[0105] Please refer to Figure 4, this embodiment is a further expansion of the above-mentioned embodiment, and the similarities will not be described again. The difference is that after step S3, the following steps are also included:

[0106] S8: Determine whether any client disconnects from the server, if yes, perform step S9.

[0107] S9: Close the connection socket corresponding to the disconnected client.

[0108] S10: Delete the connection socket from the query socket queue of the query thread receiving the connection socket, and notify the data processing thread to perform recovery processing.

[0109] In this embodiment, the performance of the server is further guaranteed by processing the abnormal connection socket.

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a communication method and system based on multi-query threads. The method includes: creating a listening socket and binding it to an IP address of a server and an available port; creating more than two query threads, Two or more data processing threads and one accepting connection thread; the accepting connection thread accepts the connection of the client through the listening socket, returns the connection socket corresponding to each client one by one, and distributes the connection socket to each query thread; each query thread receives the connection socket and stores it in its own query socket queue; according to the maximum number of connection sockets that a query thread can handle, each query thread sequentially selects from its respective query socket queue Loop out a set of connection sockets; receive the data in the connection sockets, put the data into the data queue, and process it concurrently by the data processing thread. The invention can improve the query speed of the connection socket, thereby improving the performance of the server.

Description

technical field [0001] The invention relates to the technical field of communication, in particular to a communication method and system based on multi-query threads. Background technique [0002] In general network server applications, as long as it is not dealing with large-scale connections, you can choose the network structure of the select model. Everyone generally thinks so, because the network structure of the select model seems to be a single-threaded processing logic. It is necessary to cyclically select the socket (socket). When there is a message, the select thread will return and continue the subsequent operations. The whole process is a pipeline mechanism. Accepting connections, receiving messages, and sending messages all take up Single-threaded time slice, and the select of a thread can only process 64 sockets at a time. When the number of connections exceeds 64, the efficiency of message processing is greatly reduced. [0003] In the Chinese patent publicati...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Patents(China)
IPC IPC(8): H04L29/06G06F16/2455G06F16/25
CPCH04L69/162G06F16/24568G06F16/25H04L67/133
Inventor 刘德建李上杰方振华汪松郭玉湖
Owner FUJIAN TIANQUAN EDUCATION TECH LTD