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
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
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.
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 


