CN106790022B - Communication means and its system based on more inquiry threads - Google Patents
Communication means and its system based on more inquiry threads Download PDFInfo
- Publication number
- CN106790022B CN106790022B CN201611154487.4A CN201611154487A CN106790022B CN 106790022 B CN106790022 B CN 106790022B CN 201611154487 A CN201611154487 A CN 201611154487A CN 106790022 B CN106790022 B CN 106790022B
- Authority
- CN
- China
- Prior art keywords
- socket
- connection
- inquiry
- thread
- client
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
- G06F16/24568—Data stream processing; Continuous queries
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/133—Protocols for remote procedure calls [RPC]
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Computational Linguistics (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention discloses a kind of communication means and its system based on more inquiry threads, method includes: one monitoring socket of creation, and it is bound with the IP address of server and an available port;Create more than two inquiry threads, more than two data processing threads and a receiving connection thread;Receive the connection that connection thread receives client by monitoring socket, returns and connect socket correspondingly with each client, and connection socket is distributed to each inquiry thread;Each inquiry thread receives connection socket, and is stored in respective inquiry socket queue;The accessible maximum connection number sockets of thread are inquired according to one, respectively inquiring thread, sequentially circulation takes out one group of connection socket from respective inquiry socket queue;The data in connection socket are received, and the data are put into data queue, by data processing threads concurrent processing.The present invention can promote the inquiry velocity to connection socket, to promote the performance of server.
Description
Technical field
The present invention relates to field of communication technology more particularly to a kind of communication means and its system based on more inquiry threads.
Background technique
In the application of general networking server-side, only if it were not for the large-scale connection of processing, so that it may select select model
Network structure, what everybody typically thought in this way, because of the network structure of select model, it appears that be a single thread
Processing logic, need cyclically to socket (socket) carry out select inquiry, have message come, select thread will return
It returns, and continues subsequent operation, whole process is the mechanism of an assembly line, receives connection, receives message, sends out message, all occupies
The timeslice of single thread, and the select of a thread can only once handle 64 sockets, be more than 64 in connection number
When, the efficiency of Message Processing substantially reduces.
In the Chinese patent open file of Publication No. CN104683460A, a kind of communication party of Internet of Things is disclosed
Method, comprising: multiple first selector Selector are set, with the multithreading reception connection request from connection queue;According to multiple
First Selector receives the quantity of data, determines that the first Selector receives the company for being currently at connection queue front end
Connect request;The connection with equipment side is established according to connection request.But the program receives connection request using multithreading, increases line
The time of the switching system consumption of journey, and using the monitoring of same thread progress socket, receiving connection and inquiry, line can be consumed
The performance of journey.
Summary of the invention
The technical problems to be solved by the present invention are: propose a kind of communication means and its system based on more inquiry threads,
Inquiry thread is promoted to the inquiry velocity of connection socket, to promote the performance of server.
In order to solve the above-mentioned technical problem, a kind of the technical solution adopted by the present invention are as follows: communication based on more inquiry threads
Method, comprising:
Create a monitoring socket, and by itself and the IP address of server and an available port of the server
Binding;
Create more than two inquiry threads, more than two data processing threads and a receiving connection thread;
Receive the connection that connection thread receives client by monitoring socket, return connects correspondingly with each client
Socket is connect, and connection socket is distributed to each inquiry thread;
Each inquiry thread receives the connection socket, and is stored in respective inquiry socket queue;
The accessible maximum connection number sockets of thread are inquired according to one, each thread of inquiring is from respective inquiry socket
Sequentially circulation takes out one group of connection socket in queue;
The data having in the connection socket of data in one group of connection socket are received, and the data are put into number
According to queue, by the data processing threads concurrent processing.
The invention further relates to a kind of communication systems based on more inquiry threads, comprising:
First creation module, for creating a monitoring socket, and by its IP address with server and the clothes
The available port binding of business device;
Second creation module, for creating more than two inquiry threads, more than two data processing threads and one
Receive connection thread;
Distribution module receives the connection of client by monitoring socket for receiving to connect thread, returns and each client
The one-to-one connection socket in end, and connection socket is distributed to each inquiry thread;
It is stored in module, receives the connection socket for each inquiry thread, and be stored in respective inquiry socket queue;
Module is taken out, for inquiring the accessible maximum connection number sockets of thread according to one, each thread of inquiring is from each
From inquiry socket queue in sequentially circulation take out one group of connection socket;
First is put into module, for receiving the data in the connection socket for having data in one group of connection socket,
And the data are put into data queue, by the data processing threads concurrent processing.
The beneficial effects of the present invention are: extend the ability of select using the mechanism of more inquiry threads, originally one
Inquiry thread can handle 64 connection sockets, then n inquiry thread can then handle 64*n connection socket simultaneously
Concurrent data improves the efficiency of socket inquiry, to improve the speed of Message Processing;Only setting one receives connecting line
Journey is responsible for receiving the connection of client and connects the distribution of socket, compared to being arranged for multiple receiving connection threads, reduction
Time consumed by switch threads, improve connection treatment effeciency;And socket distribution and socket inquiry are by different lines
Cheng Jinhang processing, has saved the performance of thread;Meanwhile each information trunk is distributed to by socket is connected by receiving connection thread
Journey, each connection socket inquired in thread cyclic query itself inquiry socket queue, guarantees all connection sockets all
It can be queried, also guarantee that all connection sockets all can be only queried in some inquiry thread, inquire the inquiry of thread
Socket object word in socket queue be it is unique independent, share and access is not present in the mutual resource of multithreading, without locking
Operation improves the concurrent processing speed of multithreading inquiry.
Detailed description of the invention
Fig. 1 is a kind of flow chart of the communication means based on more inquiry threads of the present invention;
Fig. 2 is the method flow diagram of the embodiment of the present invention one;
Fig. 3 is the flow chart of the step S3 of the embodiment of the present invention two;
Fig. 4 is the method flow diagram of the embodiment of the present invention three;
Fig. 5 is a kind of structural schematic diagram of the communication system based on more inquiry threads of the present invention;
Fig. 6 is the system structure diagram of the embodiment of the present invention four.
Label declaration:
1, the first creation module;2, the second creation module;3, distribution module;4, it is stored in module;5, module is taken out;6, first
It is put into module;7, third creation module;8, second it is put into module;9, module is monitored;10, closedown module;11, removing module;
31, unit is preset;32, receiving unit;33, the first Dispatching Unit;34, the second Dispatching Unit;35, unit is emptied;
36, unit is continued to execute.
Specific embodiment
To explain the technical content, the achieved purpose and the effect of the present invention in detail, below in conjunction with embodiment and cooperate attached
Figure is explained in detail.
The most critical design of the present invention is: setting multiple queries thread, improves the search efficiency of connection socket.
Referring to Fig. 1, a kind of communication means based on more inquiry threads, comprising:
Create a monitoring socket, and by itself and the IP address of server and an available port of the server
Binding;
Create more than two inquiry threads, more than two data processing threads and a receiving connection thread;
Receive the connection that connection thread receives client by monitoring socket, return connects correspondingly with each client
Socket is connect, and connection socket is distributed to each inquiry thread;
Each inquiry thread receives the connection socket, and is stored in respective inquiry socket queue;
The accessible maximum connection number sockets of thread are inquired according to one, each thread of inquiring is from respective inquiry socket
Sequentially circulation takes out one group of connection socket in queue;
The data having in the connection socket of data in one group of connection socket are received, and the data are put into number
According to queue, by the data processing threads concurrent processing.
As can be seen from the above description, the beneficial effects of the present invention are: the inquiry velocity to connection socket can be promoted, thus
Promote the performance of server.
Further, described " to receive the data having in the connection socket of data in one group of connection socket, and
The data are put into data queue, by the data processing threads concurrent processing " after, further comprise:
Create more than two data transmission line journeys;
The data for having handled and need to be sent to client are put into transmit queue, are sent to by the data transmission line journey
Corresponding client.
Seen from the above description, data transmission is carried out by data transmission line journey, realized between server end and client
Data transmission.
Further, described " one monitoring socket of creation, and by its IP address with server and the server
An available port binding " after, further comprise:
Server monitors the connection of client by the monitoring socket.
Further, described " to receive the connection that connection thread receives client by monitoring socket, return and each client
The one-to-one connection socket in end, and connection socket is distributed to each inquiry thread " specifically:
The duration of preset time piece;
Receive the connection that connection thread receives client in a timeslice by monitoring socket, returns and each client one
One corresponding connection socket, and be stored in and receive socket queue;
The connection socket received in socket queue is distributed to current connection socket number least one to look into
Ask thread;
More than two inquiry threads if it exists, then by the connection socket received in socket queue point
Issue any inquiry thread;
It empties and described receives socket queue;
Continue to execute the step for receiving connection thread and receiving the connection of client in a timeslice by monitoring socket
Suddenly.
Seen from the above description, by the distribution method of load balancing, have the function that the pressure of balanced each inquiry thread.
Further, described " to receive the connection that connection thread receives client by monitoring socket, return and each client
The one-to-one connection socket in end, and connection socket is distributed to each inquiry thread;Each inquiry thread receives the connection
Socket, and it is stored in respective inquiry socket queue " after, further comprise:
If a client disconnects the connection with server, the corresponding connection socket of a client is closed;
The connection socket is deleted from the inquiry socket queue of inquiry thread for receiving the connection socket, and
Notification data processing thread is recycled.
Seen from the above description, by handling abnormal connection socket, it is ensured that the performance of server.
Further, the ratio for the number that the inquiry thread, data processing threads and data send thread is 1:1:1.
Seen from the above description, thread is sent by the way that the inquiry thread, data processing threads and data of same number is arranged,
It can avoid the waste of thread resources.
Referring to figure 5., the present invention also proposes a kind of communication system based on more inquiry threads, comprising:
First creation module, for creating a monitoring socket, and by its IP address with server and the clothes
The available port binding of business device;
Second creation module, for creating more than two inquiry threads, more than two data processing threads and one
Receive connection thread;
Distribution module receives the connection of client by monitoring socket for receiving to connect thread, returns and each client
The one-to-one connection socket in end, and connection socket is distributed to each inquiry thread;
It is stored in module, receives the connection socket for each inquiry thread, and be stored in respective inquiry socket queue;
Module is taken out, for inquiring the accessible maximum connection number sockets of thread according to one, each thread of inquiring is from each
From inquiry socket queue in sequentially circulation take out one group of connection socket;
First is put into module, for receiving the data in the connection socket for having data in one group of connection socket,
And the data are put into data queue, by the data processing threads concurrent processing.
Further, further includes:
Third creation module, for creating more than two data transmission line journeys;
Second is put into module, transmit queue is put into for will handle and needed to be sent to the data of client, by described
Data transmission line journey is sent to corresponding client.
Further, further includes:
Module is monitored, monitors the connection of client by the monitoring socket for server.
Further, the distribution module includes:
Default unit, the duration for preset time piece;
Receiving unit connects connection of the thread by monitoring client in socket one timeslice of receiving for receiving, returns
It returns and connect socket correspondingly with each client, and be stored in and receive socket queue;
First Dispatching Unit, for the connection socket received in socket queue to be distributed to current connection socket
The least inquiry thread of word number;
Second Dispatching Unit then receives socket team for described for more than two inquiry threads if it exists
Connection socket in column is distributed to any inquiry thread;
Unit is emptied, described receives socket queue for emptying;
Unit is continued to execute, is received in a timeslice for continuing to execute the receiving connection thread by monitoring socket
The step of connection of client.
Further, further includes:
Closedown module closes the corresponding company of a client if disconnecting the connection with server for a client
Connect socket;
Removing module, described in being deleted from the inquiry socket queue of inquiry thread for receiving the connection socket
Socket is connected, and notification data processing thread is recycled.
Further, the ratio for the number that the inquiry thread, data processing threads and data send thread is 1:1:1.
Embodiment one
Referring to figure 2., the embodiment of the present invention one are as follows: a kind of communication means based on more inquiry threads, including walk as follows
It is rapid:
S1: one monitoring socket of creation, and by itself and the IP address (such as 0.0.0.0) of server and the server
An available port bind (such as 80 ports);After binding, server monitors the company of client by the monitoring socket
It connects.
S2: the more than two inquiry threads of creation, more than two data processing threads, a receiving connect thread and two
A above data transmission line journey;Wherein, thread, data processing threads and data are inquired and send the specific number of thread according to number
It is determined according to handling capacity;Preferably, it is 1 that the inquiry thread, data processing threads and data, which send the ratio of the number of thread:
1:1 can avoid the waste of thread resources.
S3: receiving the connection that connection thread receives client by monitoring socket, returns and corresponds with each client
Connection socket, and by connection socket be distributed to each inquiry thread.
S4: each inquiry thread receives the connection socket, and is stored in respective inquiry socket queue.
S5: the accessible maximum connection number sockets of thread are inquired according to one, each thread of inquiring is covered from respective inquiry
One group of connection socket of sequentially circulation taking-up in word queue is connect, then to each connector sleeve in one group of connection socket of taking-up
Connect word to be inquired, inquire whether it has data, specifically, query function can be called, judge these connection sockets in whether
There are readable data.The accessible maximum connection number sockets of one inquiry thread are 64, then one group of connection socket
Number be as much as possible 64;Preferably, in each group connection socket that one cycle is taken out, in addition to last group, remaining
The connection socket number of group is 64, if remaining connection socket number is less than 64, last group connects socket
Number be smaller than 64.
Inquiring thread is a cyclic process to the inquiry of socket is connected in inquiry socket queue, when inquiry socket
All connection sockets in queue, which are all inquired, to be gone over, and is started to query again, until program exits.It can guarantee all companies
Inquiry will not be missed by connecing socket, also guarantee that all connection sockets all can be only queried in some inquiry thread,
So that respectively the connection socket object word in the inquiry socket queue of inquiry thread is unique independent, mutual resource of multithreading
There is no share and access, are not necessarily to locking operation, improve the concurrent processing speed of multithreading inquiry.
S6: the data having in the connection socket of data in one group of connection socket are received, and the data are put
Enter data queue, by the data processing threads concurrent processing.
S7: being put into transmit queue for the data for having handled and need to be sent to client, is sent out by the data transmission line journey
It send to corresponding client.
Response priority due in existing usage scenario, inquiring the concurrent processing requirement of thread is than receiving company
The response of wiring journey wants high, and the core competence of high concurrent is to improve while handling the ability of communication data, and receive and the company of foundation
It connects this operation only to need to be implemented once the connection of a client, and concurrency can't be too high, once user connects
After coming up, all pressure has been transferred to inquiry thread, and what is tested this when is the oncurrent processing ability for inquiring thread.
So the present embodiment is using a receiving connection thread and multiple queries thread, wherein inquire the number of thread, actual conditions can
It is determined according to core cpu number, if server has 16 core CPU, 16~32 inquiry threads can be created.According to optimization
Test experiments are the result shows that the number of inquiry thread is 1~2 times of proper, certain and server machine of core cpu number
Overall performance also has relationship, so the quantity of best queries thread is 1~2 times of core cpu quantity.
The present embodiment extends the ability of select using the mechanism of more inquiry threads, and originally one inquiry thread can be located
64 connection sockets are managed, then n inquiry thread can then handle the concurrent data of 64*n connection socket simultaneously, improve
The efficiency of socket inquiry, to improve the speed of Message Processing;Only one receiving of setting connects thread to be responsible for receiving visitor
The connection at family end and the distribution for connecting socket reduce switch threads and are disappeared compared to being arranged for multiple receiving connection threads
The time of consumption improves connection treatment effeciency;And socket distribution and socket inquiry are handled by different threads, are saved
The performance of thread.
Embodiment two
Referring to figure 3., the present embodiment is the further expansion of step S3 in embodiment one, is specifically comprised the following steps:
S31: the duration of preset time piece.
S32: receiving the connection that connection thread receives client in a timeslice by monitoring socket, returns and each client
The one-to-one connection socket in end, and be stored in and receive socket queue.
S33: it is least that the connection socket received in socket queue is distributed to current connection socket number
One inquiry thread.
S34: judging whether there is more than two inquiry threads, if so, step S35 is executed, if it is not, then directly
It is distributed to the current connection least inquiry thread of socket number.
S35: the connection socket received in socket queue is distributed to any inquiry thread.
S36: it empties and described receives socket queue;Then it is next to continue through monitoring socket receiving for receiving connection thread
The connection of client in timeslice, i.e. execution step S32.
For example, it is assumed that creating three inquiries thread a, b, c, in first timeslice, receives connection thread and receive
The connection of 10 clients receives have 10 connection sockets in socket queue at this time, all due to three inquiry threads at this time
Socket is not connected, therefore is distributed to any one inquiry thread, it is assumed that is distributed to inquiry thread a, then the inquiry socket of a
There are 10 connection sockets in queue, then empty the connection socket received in socket queue, receives connection thread and continue
Receive the connection of client in future time piece;And so on, it is assumed that the company of 5 clients is received in second timeslice
It connects, and 5 connection sockets has been distributed to inquiry thread b, the connection of 15 clients is received in third timeslice, and
15 connection sockets inquiry thread c has been distributed to;At this point, the connection socket in the inquiry socket queue of inquiry thread b
The number of word is minimum, and therefore, the connection socket returned in the 4th timeslice is distributed to information trunk journey b, then determines again
New connection socket number is least out looks into new thread, then the connection socket returned in the 5th timeslice is distributed to
It, and so on.
By the distribution method of load balancing, have the function that the pressure of balanced each inquiry thread.
Embodiment three
Referring to figure 4., the present embodiment is the further expansion of above-described embodiment, and something in common is not repeated, and difference is,
Further include following steps after step S3:
S8: judging whether there is the connection of client disconnection and server, if so, executing step S9.
S9: the corresponding connection socket of the client disconnected is closed.
S10: the connection socket is deleted from the inquiry socket queue of inquiry thread for receiving the connection socket
Word, and notification data processing thread is recycled.
The present embodiment is handled abnormal connection socket by this, is further ensured that the performance of server.
Example IV
Fig. 6 is please referred to, the present embodiment is a kind of communication system based on more inquiry threads of corresponding above-described embodiment, packet
It includes:
First creation module 1, for creating a monitoring socket, and by its IP address with server and the clothes
The available port binding of business device;
Second creation module 2, for creating more than two inquiry threads, more than two data processing threads and one
Receive connection thread;
Distribution module 3 receives the connection of client by monitoring socket for receiving to connect thread, returns and each client
The one-to-one connection socket in end, and connection socket is distributed to each inquiry thread;
It is stored in module 4, receives the connection socket for each inquiry thread, and be stored in respective inquiry socket team
Column;
Module 5 is taken out, for inquiring the accessible maximum connection number sockets of thread according to one, each thread of inquiring is from each
From inquiry socket queue in sequentially circulation take out one group of connection socket;
First is put into module 6, for receiving the data in the connection socket for having data in one group of connection socket,
And the data are put into data queue, by the data processing threads concurrent processing.
Further, further includes:
Third creation module 7, for creating more than two data transmission line journeys;
Second is put into module 8, transmit queue is put into for will handle and needed to be sent to the data of client, by described
Data transmission line journey is sent to corresponding client.
Further, further includes:
Module 9 is monitored, monitors the connection of client by the monitoring socket for server.
Further, the distribution module 3 includes:
Default unit 31, the duration for preset time piece;
Receiving unit 32 connects connection of the thread by monitoring client in socket one timeslice of receiving for receiving,
It returns and connect socket correspondingly with each client, and be stored in and receive socket queue;
First Dispatching Unit 33, for the connection socket received in socket queue to be distributed to current connector sleeve
Connect the least inquiry thread of word number;
Second Dispatching Unit 34 then receives socket for described for more than two inquiry threads if it exists
Connection socket in queue is distributed to any inquiry thread;
Unit 35 is emptied, described receives socket queue for emptying;
Unit 36 is continued to execute, receives a timeslice by monitoring socket for continuing to execute the receiving connection thread
The step of connection of interior client.
Further, further includes:
It is corresponding to close a client if disconnecting the connection with server for a client for closedown module 10
Connect socket;
Removing module 11, for deleting institute from the inquiry socket queue of inquiry thread for receiving the connection socket
Connection socket is stated, and notification data processing thread is recycled.
Further, the ratio for the number that the inquiry thread, data processing threads and data send thread is 1:1:1.
In conclusion a kind of communication means and its system based on more inquiry threads provided by the invention, utilizes more inquiries
The mechanism of thread extends the ability of select, and originally one inquiry thread can handle 64 connection sockets, then n inquiry
Thread can then handle the concurrent data of 64*n connection socket simultaneously, the efficiency of socket inquiry be improved, to improve
The speed of Message Processing;Only setting one receives connection thread to be responsible for point for receiving the connection of client and connecting socket
Hair reduces the time consumed by switch threads compared to being arranged for multiple receiving connection threads, improves connection processing effect
Rate;And socket distribution and socket inquiry are handled by different threads, have saved the performance of thread;Meanwhile by connecing
It is distributed to each inquiry thread by socket is connected by connection thread, it is each to inquire in thread cyclic query itself inquiry socket queue
Connection socket, guarantee that all connection sockets can be queried, also guarantee that all connection sockets all only can be at certain
Be queried in one inquiry thread, the socket object word inquired in the inquiry socket queue of thread be it is unique independent, it is multi-thread
Share and access is not present in the mutual resource of journey, is not necessarily to locking operation, improves the concurrent processing speed of multithreading inquiry.
The above description is only an embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair
Equivalents made by bright specification and accompanying drawing content are applied directly or indirectly in relevant technical field, similarly include
In scope of patent protection of the invention.
Claims (10)
1. a kind of communication means based on more inquiry threads characterized by comprising
A monitoring socket is created, and it is tied up with the IP address of server and an available port of the server
It is fixed;
Create more than two inquiry threads, more than two data processing threads and a receiving connection thread;
Receive the connection that connection thread receives client by monitoring socket, returns and the one-to-one connector sleeve of each client
Word is connect, and connection socket is distributed to each inquiry thread;
Each inquiry thread receives the connection socket, and is stored in respective inquiry socket queue;
The accessible maximum connection number sockets of thread are inquired according to one, each thread of inquiring is from respective inquiry socket queue
In sequentially circulation take out one group of connection socket;
The data having in the connection socket of readable data in one group of connection socket are received, and the data are put into number
According to queue, by the data processing threads concurrent processing.
2. the communication means according to claim 1 based on more inquiry threads, which is characterized in that described " to receive described one
There are the data in the connection socket of data in group connection socket, and the data are put into data queue, by the data
Handle thread concurrent processing " after, further comprise:
Create more than two data transmission line journeys;
The data for having handled and need to be sent to client are put into transmit queue, correspondence is sent to by the data transmission line journey
Client.
3. the communication means according to claim 1 based on more inquiry threads, which is characterized in that described " one prison of creation
Socket is listened, and it is bound with the IP address of server and an available port of the server " after, further wrap
It includes:
Server monitors the connection of client by the monitoring socket.
4. the communication means according to claim 1 based on more inquiry threads, which is characterized in that described " to receive connecting line
Journey receives the connection of client by monitoring socket, returns and connect socket correspondingly with each client, and will connection
Socket is distributed to each inquiry thread " specifically:
The duration of preset time piece;
Receive the connection that connection thread receives client in a timeslice by monitoring socket, returns a pair of with each client one
The connection socket answered, and be stored in and receive socket queue;
The connection socket received in socket queue is distributed to the current connection least information trunk of socket number
Journey;
The connection socket received in socket queue, then be distributed to by more than two inquiry threads if it exists
Any inquiry thread;
It empties and described receives socket queue;
The connection thread that receives is continued to execute by monitoring the step of socket receives the connection of client in a timeslice.
5. the communication means according to claim 1 based on more inquiry threads, which is characterized in that described " to receive connecting line
Journey receives the connection of client by monitoring socket, returns and connect socket correspondingly with each client, and will connection
Socket is distributed to each inquiry thread;Each inquiry thread receives the connection socket, and is stored in respective inquiry socket team
After column ", further comprise:
If a client disconnects the connection with server, the corresponding connection socket of a client is closed;
The connection socket is deleted from the inquiry socket queue of inquiry thread for receiving the connection socket, and is notified
Data processing threads are recycled.
6. the communication means according to claim 2 based on more inquiry threads, which is characterized in that the inquiry thread, number
It is 1:1:1 according to the ratio that processing thread and data send the number of thread.
7. a kind of communication system based on more inquiry threads characterized by comprising
First creation module, for creating a monitoring socket, and by its IP address with server and the server
An available port binding;
Second creation module, for creating more than two inquiry threads, more than two data processing threads and a receiving
Connect thread;
Distribution module receives the connection of client by monitoring socket for receiving to connect thread, returns and each client one
One corresponding connection socket, and connection socket is distributed to each inquiry thread;
It is stored in module, receives the connection socket for each inquiry thread, and be stored in respective inquiry socket queue;
Module is taken out, for inquiring the accessible maximum connection number sockets of thread according to one, each thread of inquiring is from respective
Inquire one group of connection socket of sequentially circulation taking-up in socket queue;
First is put into module, for receiving the data in the connection socket for having readable data in one group of connection socket,
And the data are put into data queue, by the data processing threads concurrent processing.
8. the communication system according to claim 7 based on more inquiry threads, which is characterized in that further include:
Third creation module, for creating more than two data transmission line journeys;
Second is put into module, transmit queue is put into for will handle and needed to be sent to the data of client, by the data
It sends thread and is sent to corresponding client.
9. the communication system according to claim 7 based on more inquiry threads, which is characterized in that further include:
Module is monitored, monitors the connection of client by the monitoring socket for server.
10. the communication system according to claim 7 based on more inquiry threads, which is characterized in that the distribution module packet
It includes:
Default unit, the duration for preset time piece;
Receiving unit, for receive connect thread by monitor socket receive a timeslice in client connection, return with
Each client connects socket correspondingly, and is stored in and receives socket queue;
First Dispatching Unit, for the connection socket received in socket queue to be distributed to current connection socket
The least inquiry thread of number;
Second Dispatching Unit then receives described in socket queue for more than two inquiry threads if it exists
Connection socket be distributed to any inquiry thread;
Unit is emptied, described receives socket queue for emptying;
Unit is continued to execute, receives client in a timeslice by monitoring socket for continuing to execute the receiving connection thread
The step of connection at end.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611154487.4A CN106790022B (en) | 2016-12-14 | 2016-12-14 | Communication means and its system based on more inquiry threads |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611154487.4A CN106790022B (en) | 2016-12-14 | 2016-12-14 | Communication means and its system based on more inquiry threads |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106790022A CN106790022A (en) | 2017-05-31 |
CN106790022B true CN106790022B (en) | 2019-06-18 |
Family
ID=58888794
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611154487.4A Active CN106790022B (en) | 2016-12-14 | 2016-12-14 | Communication means and its system based on more inquiry threads |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106790022B (en) |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107454167A (en) * | 2017-08-04 | 2017-12-08 | 深圳市元征科技股份有限公司 | Request processing method and server |
CN110020359B (en) * | 2017-11-08 | 2024-04-05 | 亿阳信通股份有限公司 | Data processing method, device and storage medium applied to front end of webpage |
CN108647104B (en) * | 2018-05-15 | 2022-05-31 | 北京五八信息技术有限公司 | Request processing method, server and computer readable storage medium |
CN110187979B (en) * | 2019-04-09 | 2021-05-18 | 口口相传(北京)网络技术有限公司 | Link message processing method and device, storage medium and computer equipment |
CN111159236A (en) * | 2019-12-23 | 2020-05-15 | 五八有限公司 | Data processing method and device, electronic equipment and storage medium |
CN113162932B (en) * | 2021-04-23 | 2023-01-06 | 航天新通科技有限公司 | Asynchronous I/O operation method and device based on socket |
CN113360525B (en) * | 2021-08-10 | 2021-12-07 | 支付宝(杭州)信息技术有限公司 | Query request processing method, device and equipment and key value query system |
CN114449062B (en) * | 2021-12-31 | 2023-10-24 | 广东国腾量子科技有限公司 | Interactive system and method of QKD key management system |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102916953A (en) * | 2012-10-12 | 2013-02-06 | 青岛海信传媒网络技术有限公司 | Method and device for realizing concurrent service on basis of TCP (transmission control protocol) connection |
CN103501245A (en) * | 2013-09-26 | 2014-01-08 | 北京搜狐互联网信息服务有限公司 | Network-event processing method and device |
CN103914471A (en) * | 2012-12-31 | 2014-07-09 | 北京启明星辰信息技术股份有限公司 | Mass event processing method and device |
CN105553977A (en) * | 2015-12-15 | 2016-05-04 | 网易(杭州)网络有限公司 | Request message processing and transmitting method and device |
-
2016
- 2016-12-14 CN CN201611154487.4A patent/CN106790022B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102916953A (en) * | 2012-10-12 | 2013-02-06 | 青岛海信传媒网络技术有限公司 | Method and device for realizing concurrent service on basis of TCP (transmission control protocol) connection |
CN103914471A (en) * | 2012-12-31 | 2014-07-09 | 北京启明星辰信息技术股份有限公司 | Mass event processing method and device |
CN103501245A (en) * | 2013-09-26 | 2014-01-08 | 北京搜狐互联网信息服务有限公司 | Network-event processing method and device |
CN105553977A (en) * | 2015-12-15 | 2016-05-04 | 网易(杭州)网络有限公司 | Request message processing and transmitting method and device |
Also Published As
Publication number | Publication date |
---|---|
CN106790022A (en) | 2017-05-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106790022B (en) | Communication means and its system based on more inquiry threads | |
CN111580995A (en) | Synchronous communication method and system of distributed cloud platform and Internet of things intelligent terminal based on MQTT asynchronous communication scene | |
CN110677277B (en) | Data processing method, device, server and computer readable storage medium | |
CN102916953A (en) | Method and device for realizing concurrent service on basis of TCP (transmission control protocol) connection | |
CN101262372B (en) | Method for video monitoring platform to operate and control front-end device based on SIP server cluster | |
CN108063813B (en) | Method and system for parallelizing password service network in cluster environment | |
CN101753597B (en) | Keeping alive method between peer node and client under peer node-client architecture | |
CN103532876A (en) | Processing method and system of data stream | |
CN102571568B (en) | Method and device for processing task | |
CN102316160A (en) | Website system and communication method thereof | |
CN109495383B (en) | Data processing method, device, communication system and network equipment | |
CN108123826B (en) | Cross-region data interaction system and method | |
US8606908B2 (en) | Wake-up server | |
CN116680035A (en) | GPU (graphics processing unit) method and device for realizing remote scheduling of kubernetes container | |
CN103795603A (en) | Edge virtual bridging method and device based on multiple network interface cards | |
CN110321203B (en) | Background process false death processing method and client | |
CN102761608A (en) | UDP (User Datagram Protocol) conversation multiplexing method and load balancing equipment | |
CN103685480A (en) | Transmission control protocol (TCP) network implementing method and server | |
CN109889406A (en) | For managing method, apparatus, equipment and the storage medium of network connection | |
CN104079398B (en) | A kind of data communications method, apparatus and system | |
CN103905484A (en) | Method of processing hyper text transport protocol (HTTP) requests and device | |
CN105357148A (en) | Method and system for preventing output message of network exchange chip from being disordered | |
CN108429703A (en) | Dhcp client loading method and device | |
CN104253702A (en) | Terminal management method and system | |
CN104639379A (en) | Proxy testing method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |