CN119052310B - TCP connection management method, TCP connection management device, electronic equipment, storage medium and program product - Google Patents
TCP connection management method, TCP connection management device, electronic equipment, storage medium and program product Download PDFInfo
- Publication number
- CN119052310B CN119052310B CN202411555445.6A CN202411555445A CN119052310B CN 119052310 B CN119052310 B CN 119052310B CN 202411555445 A CN202411555445 A CN 202411555445A CN 119052310 B CN119052310 B CN 119052310B
- Authority
- CN
- China
- Prior art keywords
- tcp connection
- connection channel
- client
- preset event
- tcp
- 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
- 238000007726 management method Methods 0.000 title claims abstract description 41
- 238000012544 monitoring process Methods 0.000 claims abstract description 27
- 238000000034 method Methods 0.000 claims abstract description 26
- 230000005540 biological transmission Effects 0.000 claims abstract description 21
- 238000004590 computer program Methods 0.000 claims description 17
- 230000000694 effects Effects 0.000 description 5
- 230000006854 communication Effects 0.000 description 4
- 238000004891 communication Methods 0.000 description 4
- 230000007246 mechanism Effects 0.000 description 4
- 238000012545 processing Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 230000001360 synchronised effect Effects 0.000 description 3
- 238000001514 detection method Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000007175 bidirectional communication Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000004140 cleaning Methods 0.000 description 1
- 238000012790 confirmation Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000011084 recovery Methods 0.000 description 1
- 239000000523 sample Substances 0.000 description 1
Classifications
-
- 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/14—Session management
-
- 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/163—In-band adaptation of TCP data exchange; In-band control procedures
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer Security & Cryptography (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention relates to a TCP connection management method, a device, electronic equipment, a storage medium and a program product, which comprise setting a timing strategy matched with a preset event according to the event content of the preset event, wherein the preset event comprises any item of no data reading operation on a TCP connection channel of a transmission control protocol between a client and a server, no data writing operation on the TCP connection channel, no data reading operation and no data writing operation on the TCP connection channel, polling to monitor whether the preset event occurs on the TCP connection channel according to the timing strategy matched with the preset event, and managing the TCP connection channel according to the monitoring condition based on a key value formed by identification information of the client and connection information of the TCP connection channel. The method can improve the management efficiency of TCP connection.
Description
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method, an apparatus, an electronic device, a storage medium, and a program product for TCP connection management.
Background
The transmission control protocol (Transmission Control Protocol, TCP) is a reliable byte stream based communication protocol for multi-device interconnection, and its main function is to establish a stable data transmission connection between two computers, ensuring sequential transmission of data packets, integrity of data, and detection and recovery of errors. When the network communication adopts TCP/IP protocol, a TCP connection needs to be established between the client and the server before the operations such as reading and writing are performed, and the TCP connection is released after the reading and writing operations are finished.
TCP connections require a timeout heartbeat mechanism to detect if the connection is still active. A heartbeat mechanism refers to the confirmation that a connection is still valid and active by sending a signal (typically a null message or a specific probe packet) periodically, and a timeout mechanism refers to the fact that the system will consider the connection to be potentially dead if no heartbeat signal or any data is received within a specified time. However, the existing TCP connection management method manages different operation events by adopting the same timeout heartbeat mechanism, so that it is difficult to quickly respond to abrupt changes of network conditions or changes of loads in a dynamic network environment, thereby resulting in lower management efficiency.
Disclosure of Invention
The invention aims to provide a TCP connection management method, a device, electronic equipment, a storage medium and a program product, which are used for solving the defects in the prior art, and the technical problems to be solved by the invention are realized by the following technical scheme.
According to a first aspect of the present disclosure, there is provided a TCP connection management method, the method comprising:
setting a timing strategy matched with a preset event according to the event content of the preset event, wherein the preset event comprises any one of the following items that a Transmission Control Protocol (TCP) connection channel between a client and a server has no data reading operation, the TCP connection channel has no data writing operation, and the TCP connection channel has no data reading operation and no data writing operation;
according to a timing strategy matched with the preset event, polling to monitor whether the preset event occurs on the TCP connection channel;
And managing the TCP connection channel based on a key value formed by the identification information of the client and the connection information of the TCP connection channel according to the monitoring condition, wherein the identification information of the client comprises any one of an Internet Protocol (IP) address of the client or a port number of the client, the connection information of the TCP connection channel comprises at least one of the identification information of the TCP connection channel, the connection state of the TCP connection channel, the latest active time stamp of the TCP connection channel and the data transmission quantity of the TCP connection channel.
Further, before the timing strategy matched with the preset event is set according to the event content of the preset event, the method further comprises:
Acquiring a TCP connection request sent by a client;
based on the TCP connection request, establishing a TCP connection channel between the client and the server;
And after the TCP connection channel is established, storing a key value pair consisting of the identification information of the client and the connection information of the TCP connection channel into a database.
Further, according to the monitoring situation, the managing the TCP connection channel based on a key value composed of the identification information of the TCP connection channel and the connection information of the TCP connection channel includes:
under the condition that the preset event occurs on the TCP connection channel, disconnecting the TCP connection channel;
And deleting a key value pair consisting of the identification information of the client and the connection information of the TCP connection channel in the database after disconnecting the TCP connection channel.
Further, after the key value pair consisting of the identification information of the client and the connection information of the TCP connection channel is stored in the database, the method further includes:
Acquiring the resource capacity of a server side;
calculating the maximum TCP connection channel number which can be connected with the server according to the resource capacity;
determining a threshold value of the number of the TCP connection channels which can be connected with the client based on the maximum number of the TCP connection channels and the use information of the client;
inquiring the number of key value pairs corresponding to the client in a database according to the identification information of the client;
And under the condition that the key value pair number corresponding to the client is larger than the TCP connection channel number threshold value, limiting the client to establish a new TCP connection channel with the server.
Further, the polling monitoring whether the preset event occurs on the TCP connection channel according to the timing strategy matched with the preset event includes:
Acquiring a time stamp of the latest data reading operation and/or data writing operation on the TCP connection channel according to a monitoring time interval matched with the preset event;
calculating the difference value between the time stamp of the latest data reading operation and/or data writing operation on the TCP connection channel and the current time stamp;
and comparing the difference value with an idle time threshold value matched with the preset event, and judging whether the preset event occurs on the TCP connection channel.
According to a second aspect of the present disclosure, there is provided a TCP connection management apparatus, the apparatus comprising:
The first setting module is used for setting a timing strategy matched with a preset event according to the event content of the preset event, wherein the preset event comprises any one of a Transmission Control Protocol (TCP) connection channel between a client and a server without data reading operation, a TCP connection channel without data writing operation and a TCP connection channel without data reading operation and without data writing operation;
The first monitoring module is used for polling and monitoring whether the preset event occurs on the TCP connection channel according to a timing strategy matched with the preset event;
The first management module is used for managing the TCP connection channel based on a key value formed by the identification information of the client and the connection information of the TCP connection channel according to the monitoring condition, wherein the identification information of the client comprises any one of an Internet Protocol (IP) address of the client or a port number of the client, the connection information of the TCP connection channel comprises at least one of the identification information of the TCP connection channel, a connection state of the TCP connection channel, a latest active time stamp of the TCP connection channel and a data transmission quantity of the TCP connection channel.
According to a third aspect of the present disclosure, an electronic device is provided. The electronic device comprises a memory and a processor, wherein the memory stores a computer program, and the processor realizes the method when executing the computer program.
According to a fourth aspect of the present disclosure, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method.
According to a fifth aspect of the present disclosure, there is provided a computer program product comprising computer instructions which, when executed by a processor, implement the method.
The embodiment of the invention has the following advantages:
The TCP connection management method, the device, the electronic equipment, the storage medium and the program product comprise setting a timing strategy matched with a preset event according to event content of the preset event, wherein the preset event comprises any one of an Internet Protocol (IP) address of a client or a port number of the client, no data writing operation exists on a TCP connection channel, no data reading operation and no data writing operation exist on the TCP connection channel, according to the timing strategy matched with the preset event, polling to monitor whether the preset event occurs on the TCP connection channel, and according to monitoring conditions, managing the TCP connection channel based on a key value formed by identification information of the client and connection information of the TCP connection channel, wherein the identification information of the client comprises at least one of the identification information of the TCP connection channel, the connection information of the TCP connection channel comprises an Internet Protocol (IP) address of the client or a port number of the client, and the connection information of the TCP connection channel comprises a latest transmission time stamp of the TCP connection channel. According to the method, different timing strategies are set according to different preset events, so that the connection state of the TCP connection channel can be accurately identified and detected, the TCP connection channel based on the connection state of the TCP connection channel is managed through a key value formed by the identification information of the client and the connection information of the TCP connection channel, detailed information of each TCP connection channel can be conveniently recorded, and resources can be better and dynamically allocated by the system through analyzing the stored connection information, so that the management efficiency of TCP connection is improved.
Drawings
FIG. 1 is a flow chart of steps of an embodiment of a TCP connection management method of the present invention;
Fig. 2 is a schematic structural view of an embodiment of a TCP connection management apparatus according to the present invention;
Fig. 3 is a schematic structural view of an electronic device of the present invention.
Detailed Description
It should be noted that, without conflict, the embodiments of the present application and features of the embodiments may be combined with each other. The application will be described in detail below with reference to the drawings in connection with embodiments.
Fig. 1 shows a flowchart of a TCP connection management method 100, which may be performed by a TCP connection management system, in particular, the method 100 includes:
S101, setting a timing strategy matched with a preset event according to the event content of the preset event, wherein the preset event comprises any one of a Transmission Control Protocol (TCP) connection channel between a client and a server without data reading operation, a TCP connection channel without data writing operation and a TCP connection channel without data reading operation and data writing operation;
In this step, an event handler in the TCP connection management system may be defined to handle three types of events, no data read operation on the TCP connection channel between the client and server, no data write operation on the TCP connection channel between the client and server, and neither data read operation nor data write operation on the TCP channel between the client and server.
The state and the activity of the TCP connection channel between the client and the server can be detected through the events.
There are different characteristics and resource requirements due to different operations (data read operation, data write operation, or both). For example, data reads may be more passive waiting, while data writes are typically more active and frequent. The same timeout heartbeat strategy cannot effectively meet these different requirements, which may result in some connections failing to detect an inactive state in time or misjudging an active state.
Therefore, in this step, different timers are set for different preset events, that is, different timing strategies are set for different preset times, and according to the set time interval matched with the preset events, the TCP connection management system periodically checks the TCP connection channel to detect whether the preset event occurs on the TCP connection channel.
Illustratively:
1. Data read operations may sometimes be in a wait state, i.e., the client is waiting for data from the server. Longer timeout times may be set because read operations may be infrequent. If a connection does not receive a data packet for a long period of time, a heartbeat packet may need to be sent to detect connection activity to ensure that both parties are still communicable.
2. Data writing is typically active, meaning that the client continually sends data to the server. A shorter timeout time may be set because data write operations are typically more frequent and stable. If a long inactivity period occurs during writing, this may indicate a problem, requiring fast detection and processing.
3. The bidirectional communication of simultaneously reading and writing data means that the connection should always be kept active, while data transmission and reception are performed. The two conditions are needed to be considered comprehensively, and the overtime parameter is flexibly adjusted to adapt to synchronous dynamic changes of reading and writing.
S102, according to a timing strategy matched with the preset event, polling to monitor whether the preset event occurs on the TCP connection channel;
In some embodiments, the polling to monitor whether the preset event occurs on the TCP connection channel according to the timing policy matched with the preset event includes:
Acquiring a time stamp of the latest data reading operation and/or data writing operation on the TCP connection channel according to a monitoring time interval matched with the preset event;
calculating the difference value between the time stamp of the latest data reading operation and/or data writing operation on the TCP connection channel and the current time stamp;
and comparing the difference value with an idle time threshold value matched with the preset event, and judging whether the preset event occurs on the TCP connection channel.
In the above embodiment, taking the case of monitoring the data writing operation on the TCP connection channel as an example, the data reading operation on the TCP connection channel is checked according to the set monitoring time interval (such as monitoring once for 5 seconds), then the difference between the time stamp of the last data reading operation on the TCP connection channel and the current time stamp is calculated, and if the difference exceeds the preset space time threshold, it is indicated that the data writing operation has not been performed for a long time on the TCP connection channel.
This embodiment may be able to more accurately and efficiently handle various possible scenarios in network communications by matching different timing strategies for different preset events.
And S103, managing the TCP connection channel based on a key value formed by the identification information of the client and the connection information of the TCP connection channel according to the monitoring condition, wherein the identification information of the client comprises any one of an Internet Protocol (IP) address of the client or a port number of the client, the connection information of the TCP connection channel comprises at least one of the identification information of the TCP connection channel, the connection state of the TCP connection channel, the latest activity time stamp of the TCP connection channel and the data transmission quantity of the TCP connection channel.
In this step, the connection manager in the TCP connection management system can manage the TCP connection channel by a key (key) -value composed of the identification information of the client and the connection information of the TCP connection channel. The identification information of the client may be an internet protocol (Internet Protocol, IP) address of the client or a port number of the client, and the connection information of the TCP connection channel may include at least one of identification information of the TCP connection channel, a connection state of the TCP connection channel, a latest active time stamp of the TCP connection channel, and a data transmission amount of the TCP connection channel.
Taking monitoring the data writing operation on the TCP connection channel as an example, if the TCP connection channel performs the data writing operation within a preset idle time interval, finding a corresponding value according to the identification information (key) of the client, and updating the connection state of the TCP connection channel, the timestamp of the latest data writing operation and the data amount of the data writing operation.
If the TCP connection channel does not perform data writing operation for a long time, a corresponding value can be found according to the identification information (key) of the client and deleted.
In some embodiments, before the setting of the timing policy matched with the preset event according to the event content of the preset event, the method further includes:
Acquiring a TCP connection request sent by a client;
based on the TCP connection request, establishing a TCP connection channel between the client and the server;
And after the TCP connection channel is established, storing a key value pair consisting of the identification information of the client and the connection information of the TCP connection channel into a database.
In the above embodiment, when the TCP connection channel is established between the client and the server, the key value pair formed by the identification information of the client and the connection information of the TCP connection channel may be stored in the database. Therefore, the detailed information of each TCP connection can be conveniently recorded, and the system can better dynamically allocate resources by analyzing the stored connection information, so that the management efficiency of the TCP connection is improved.
In some embodiments, the managing the TCP connection channel based on a key value composed of the identification information of the TCP connection channel and the connection information of the TCP connection channel according to the listening situation includes:
under the condition that the preset event occurs on the TCP connection channel, disconnecting the TCP connection channel;
And deleting a key value pair consisting of the identification information of the client and the connection information of the TCP connection channel in the database after disconnecting the TCP connection channel.
In the above embodiment, taking the case of monitoring the data writing operation on the TCP connection channel continuously, if the TCP connection channel does not perform the data writing operation for a long time, it may be considered that the TCP connection channel may not be needed any more, and in order to release the occupied network and system resources, the system may actively disconnect the TCP connection channel that does not have the writing activity for a long time. After the connection is broken, the record associated with the connection (the key-value pair consisting of the client identification information and the connection information) may be deleted from the database.
The embodiment actively disconnects the TCP connection which is inactive for a long time, which is beneficial to releasing limited resources such as memory, ports, bandwidth and the like of a server, improves the capability of a system for processing new and active requests, ensures the consistency and accuracy of data by periodically cleaning useless entries in a database, and avoids subsequent business logic from making an error decision based on outdated or invalid data.
In some embodiments, after the storing, in a database, the key value pair consisting of the identification information of the client and the connection information of the TCP connection channel, the method further includes:
Acquiring the resource capacity of a server side;
calculating the maximum TCP connection channel number which can be connected with the server according to the resource capacity;
determining a threshold value of the number of the TCP connection channels which can be connected with the client based on the maximum number of the TCP connection channels and the use information of the client;
inquiring the number of key value pairs corresponding to the client in a database according to the identification information of the client;
And under the condition that the key value pair number corresponding to the client is larger than the TCP connection channel number threshold value, limiting the client to establish a new TCP connection channel with the server.
In the above embodiment, the resource capacity of the server is obtained by identifying and evaluating the hardware and software resources (such as the central processing unit (Central Processing Unit, CPU), the memory, the bandwidth, etc.) of the server, so as to know how many concurrent TCP connections can be supported. And calculating based on the resource capacity to obtain the maximum stable TCP connection number which can be processed by the server. Based on the calculated maximum number of connections, in combination with the usage information of each client (possibly including its resource requirements, priority, etc.), a specific upper limit of the number of connections, i.e. "threshold number of TCP connection channels", is set for each client. And searching corresponding connection information in a database by using the identification information of the client, and determining the number of the currently established connection (through the existing key value pair) of the client. If the number of connections established by a client exceeds a threshold set for the client, the client is prevented from establishing a new connection so as not to overload server resources.
In this embodiment, the number of TCP connections is limited, so that the server can be prevented from receiving too many requests to overload operation, thereby maintaining system performance and service quality, and ensuring that all clients get fair treatment when competing for limited resources, especially in a multi-user environment, so as to avoid a single user occupying too many resources.
According to the embodiment of the disclosure, a TCP connection management method comprises setting a timing strategy matched with a preset event according to event content of the preset event, wherein the preset event comprises any one of an Internet Protocol (IP) address of a client or a port number of the client, wherein no data writing operation exists on the TCP connection channel, no data reading operation exists on the TCP connection channel and no data writing operation exists on the TCP connection channel, polling to monitor whether the preset event occurs on the TCP connection channel according to the timing strategy matched with the preset event, and managing the TCP connection channel according to a monitoring condition based on a key value formed by identification information of the client and connection information of the TCP connection channel, wherein the identification information of the client comprises any one of an IP address of the client or a port number of the client, the connection information of the TCP connection channel comprises at least one of identification information of the TCP connection channel, connection state of the TCP connection channel, latest active time stamp of the TCP connection channel, and data transmission stamp of the TCP connection channel. According to the method, different timing strategies are set according to different preset events, so that the connection state of the TCP connection channel can be accurately identified and detected, the TCP connection channel based on the connection state of the TCP connection channel is managed through a key value formed by the identification information of the client and the connection information of the TCP connection channel, detailed information of each TCP connection channel can be conveniently recorded, and resources can be better and dynamically allocated by the system through analyzing the stored connection information, so that the management efficiency of TCP connection is improved.
It should be noted that, for simplicity of description, the foregoing method embodiments are all described as a series of acts, but it should be understood by those skilled in the art that the present disclosure is not limited by the order of acts described, as some steps may be performed in other orders or concurrently in accordance with the present disclosure. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all alternative embodiments, and that the acts and modules referred to are not necessarily required by the present disclosure.
The foregoing is a description of embodiments of the method, and the following further describes embodiments of the present disclosure through examples of apparatus.
Fig. 2 shows a block diagram of a TCP connection management apparatus 200 according to an embodiment of the disclosure, the apparatus 200 comprising:
A first setting module 201, configured to set a timing policy matched with a preset event according to an event content of the preset event, where the preset event includes any one of a transmission control protocol TCP connection channel between a client and a server without a data reading operation, a TCP connection channel without a data writing operation, and a TCP connection channel without a data reading operation and a data writing operation;
A first monitoring module 202, configured to poll and monitor whether the preset event occurs on the TCP connection channel according to a timing policy matched with the preset event;
the first management module 203 is configured to manage, according to a listening situation, a TCP connection channel based on a key value formed by identification information of a client and connection information of the TCP connection channel, where the identification information of the client includes any one of an internet protocol IP address of the client or a port number of the client, the connection information of the TCP connection channel includes at least one of identification information of the TCP connection channel, a connection state of the TCP connection channel, a latest activity timestamp of the TCP connection channel, and a data transmission amount of the TCP connection channel.
Further, the apparatus further comprises:
the first acquisition module is used for acquiring a TCP connection request sent by the client;
The first establishing module is used for establishing a TCP connection channel between the client and the server based on the TCP connection request;
And the first storage module is used for storing a key value pair consisting of the identification information of the client and the connection information of the TCP connection channel into a database after the TCP connection channel is established.
Further, the first management module includes:
the first disconnection unit is used for disconnecting the TCP connection channel under the condition that the preset event occurs on the TCP connection channel;
And the first deleting unit is used for deleting a key value pair formed by the identification information of the client and the connection information of the TCP connection channel in the database after the TCP connection channel is disconnected.
Further, the apparatus further comprises:
the first acquisition module is used for acquiring the resource capacity of the server side;
the first calculation module is used for calculating the maximum TCP connection channel number which can be connected with the server according to the resource capacity;
A first determining module, configured to determine a threshold number of TCP connection channels that the client can connect to, based on the maximum number of TCP connection channels and usage information of the client;
The first query module is used for querying the number of key value pairs corresponding to the client in a database according to the identification information of the client;
And the first limiting module is used for limiting the client and the server to establish a new TCP connection channel under the condition that the key value pair number corresponding to the client is larger than the TCP connection channel number threshold value.
Further, the first monitoring module includes:
The first acquisition unit is used for acquiring the time stamp of the latest data reading operation and/or data writing operation on the TCP connection channel according to the monitoring time interval matched with the preset event;
A first calculating unit, configured to calculate a difference value between a timestamp of a latest data reading operation and/or a data writing operation on the TCP connection channel and a current timestamp;
And the first judging unit is used for comparing the difference value with the idle time threshold value matched with the preset event and judging whether the preset event occurs on the TCP connection channel.
Fig. 3 illustrates a physical structure diagram of an electronic device, which may be an intelligent terminal, and an internal structure diagram thereof may be as shown in fig. 3. The electronic device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the electronic device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements the TCP connection management method described above.
On the other hand, the invention also provides a computer storage medium which stores a computer program, and the TCP connection management method is realized when the computer program is executed by a processor.
In yet another aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the electronic device reads the computer instructions from the computer readable storage medium, and the processor implements the TCP connection management method described above when executing the computer instructions.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (ErasablePROM, EPROM), electrically erasable ROM (EEPROM), or flash Memory. Volatile memory can include Random Access Memory (RAM) or external cache memory.
By way of illustration and not limitation, random access memory (Random Access Memory, RAM) is available in a variety of forms, such as static RAM (STATIC RAM, SRAM), dynamic RAM (DYNAMIC RAM, DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (Double DATA RATE SDRAM, DDRSDRAM), enhanced SDRAM (ENHANCEDSDRAM, ESDRAM), synchronous link DRAM (SYNCHLINK DRAM, SLDRAM), memory bus Direct RAM (RambusDirect RAM, RDRAM), direct memory bus dynamic RAM (Direct Rambus DYNAMIC RAM, DRDRAM), and memory bus dynamic RAM (Rambus DYNAMIC RAM, RDRAM), among others.
It should be noted that the foregoing detailed description is exemplary and is intended to provide further explanation of the application. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs.
It is noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of exemplary embodiments according to the present application. As used herein, the singular is intended to include the plural unless the context clearly indicates otherwise. Furthermore, it will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, steps, operations, devices, components, and/or groups thereof.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or otherwise described herein.
Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those elements but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Spatially relative terms, such as "above," "upper" and "upper surface," "above" and the like, may be used herein for ease of description to describe one device or feature's spatial relationship to another device or feature as illustrated in the figures. It will be understood that the spatially relative terms are intended to encompass different orientations in use or operation in addition to the orientation depicted in the figures. For example, if the device in the figures is turned over, elements described as "above" or "over" other devices or structures would then be oriented "below" or "beneath" the other devices or structures. Thus, the process is carried out, the exemplary term "above" may be included. Upper and lower. Two orientations below. The device may also be positioned in other different ways, such as rotated 90 degrees or at other orientations, and the spatially relative descriptors used herein interpreted accordingly.
In the above detailed description, reference is made to the accompanying drawings, which form a part hereof. In the drawings, like numerals typically identify like components unless context indicates otherwise. The illustrated embodiments described in the detailed description, drawings, and claims are not meant to be limiting. Other embodiments may be utilized, and other changes may be made, without departing from the spirit or scope of the subject matter presented herein.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (8)
1. A method for TCP connection management, the method comprising:
setting a timing strategy matched with a preset event according to the event content of the preset event, wherein the preset event comprises any one of the following items that a Transmission Control Protocol (TCP) connection channel between a client and a server has no data reading operation, the TCP connection channel has no data writing operation, and the TCP connection channel has no data reading operation and no data writing operation;
according to a timing strategy matched with the preset event, polling to monitor whether the preset event occurs on the TCP connection channel;
Managing the TCP connection channel based on a key value formed by the identification information of the client and the connection information of the TCP connection channel according to the monitoring condition, wherein the identification information of the client comprises any one of an Internet Protocol (IP) address of the client or a port number of the client, the connection information of the TCP connection channel comprises at least one of the identification information of the TCP connection channel, a connection state of the TCP connection channel, a latest active time stamp of the TCP connection channel and a data transmission quantity of the TCP connection channel;
The managing the TCP connection channel based on a key value composed of the identification information of the TCP connection channel and the connection information of the TCP connection channel according to the monitoring condition includes:
under the condition that the preset event occurs on the TCP connection channel, disconnecting the TCP connection channel;
After the TCP connection channel is disconnected, deleting a key value pair consisting of the identification information of the client and the connection information of the TCP connection channel in a database;
The polling monitoring whether the preset event occurs on the TCP connection channel according to the timing strategy matched with the preset event comprises the following steps:
Acquiring a time stamp of the latest data reading operation and/or data writing operation on the TCP connection channel according to a monitoring time interval matched with the preset event;
calculating the difference value between the time stamp of the latest data reading operation and/or data writing operation on the TCP connection channel and the current time stamp;
and comparing the difference value with an idle time threshold value matched with the preset event, and judging whether the preset event occurs on the TCP connection channel.
2. The TCP connection management method of claim 1, wherein said method further comprises, prior to setting a timing policy matching a preset event according to an event content of said preset event:
Acquiring a TCP connection request sent by a client;
based on the TCP connection request, establishing a TCP connection channel between the client and the server;
And after the TCP connection channel is established, storing a key value pair consisting of the identification information of the client and the connection information of the TCP connection channel into a database.
3. The TCP connection management method according to claim 2, wherein after said storing a key value pair composed of the identification information of said client and the connection information of said TCP connection channel in a database, said method further comprises:
Acquiring the resource capacity of the server side;
calculating the maximum TCP connection channel number which can be connected with the server according to the resource capacity;
determining a threshold value of the number of the TCP connection channels which can be connected with the client based on the maximum number of the TCP connection channels and the use information of the client;
inquiring the number of key value pairs corresponding to the client in a database according to the identification information of the client;
And under the condition that the key value pair number corresponding to the client is larger than the TCP connection channel number threshold value, limiting the client to establish a new TCP connection channel with the server.
4. A TCP connection management apparatus for performing the TCP connection management method according to any one of claims 1 to 3, said apparatus comprising:
The first setting module is used for setting a timing strategy matched with a preset event according to the event content of the preset event, wherein the preset event comprises any one of a Transmission Control Protocol (TCP) connection channel between a client and a server without data reading operation, a TCP connection channel without data writing operation and a TCP connection channel without data reading operation and without data writing operation;
The first monitoring module is used for polling and monitoring whether the preset event occurs on the TCP connection channel according to a timing strategy matched with the preset event;
The first management module is used for managing the TCP connection channel based on a key value formed by the identification information of the client and the connection information of the TCP connection channel according to the monitoring condition, wherein the identification information of the client comprises any one of an Internet Protocol (IP) address of the client or a port number of the client, the connection information of the TCP connection channel comprises at least one of the identification information of the TCP connection channel, a connection state of the TCP connection channel, a latest active time stamp of the TCP connection channel and a data transmission quantity of the TCP connection channel.
5. The connection management apparatus according to claim 4, wherein the apparatus further comprises:
the first acquisition module is used for acquiring a TCP connection request sent by the client;
The first establishing module is used for establishing a TCP connection channel between the client and the server based on the TCP connection request;
And the first storage module is used for storing a key value pair consisting of the identification information of the client and the connection information of the TCP connection channel into a database after the TCP connection channel is established.
6. An electronic device comprising a processor, a memory and a computer program stored on the memory and executable on the processor, which when executed by the processor implements the steps of the TCP connection management method according to any of claims 1 to 3.
7. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the TCP connection management method according to any of claims 1 to 3.
8. A computer program product comprising computer instructions which, when executed by a processor, implement the steps of the TCP connection management method of any of claims 1 to 3.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411555445.6A CN119052310B (en) | 2024-11-04 | 2024-11-04 | TCP connection management method, TCP connection management device, electronic equipment, storage medium and program product |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411555445.6A CN119052310B (en) | 2024-11-04 | 2024-11-04 | TCP connection management method, TCP connection management device, electronic equipment, storage medium and program product |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN119052310A CN119052310A (en) | 2024-11-29 |
| CN119052310B true CN119052310B (en) | 2025-03-04 |
Family
ID=93582282
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202411555445.6A Active CN119052310B (en) | 2024-11-04 | 2024-11-04 | TCP connection management method, TCP connection management device, electronic equipment, storage medium and program product |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN119052310B (en) |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116795905A (en) * | 2022-08-02 | 2023-09-22 | 中移(苏州)软件技术有限公司 | Data visualization method, device, equipment and computer storage medium |
| CN117290007A (en) * | 2023-09-04 | 2023-12-26 | 北京航空航天大学 | Server-free calculation synchronous trigger and application method thereof |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US9614861B2 (en) * | 2015-08-26 | 2017-04-04 | Microsoft Technology Licensing, Llc | Monitoring the life cycle of a computer network connection |
| CN118677940A (en) * | 2023-03-17 | 2024-09-20 | 曙光网络科技有限公司 | Management system, method, device and storage medium for transmission control protocol connection |
-
2024
- 2024-11-04 CN CN202411555445.6A patent/CN119052310B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116795905A (en) * | 2022-08-02 | 2023-09-22 | 中移(苏州)软件技术有限公司 | Data visualization method, device, equipment and computer storage medium |
| CN117290007A (en) * | 2023-09-04 | 2023-12-26 | 北京航空航天大学 | Server-free calculation synchronous trigger and application method thereof |
Also Published As
| Publication number | Publication date |
|---|---|
| CN119052310A (en) | 2024-11-29 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| EP2563062B1 (en) | Long connection management apparatus and link resource management method for long connection communication | |
| US10609150B2 (en) | Lock management method in cluster, lock server, and client | |
| US8260924B2 (en) | User load balancing systems and methods thereof | |
| KR102167613B1 (en) | Message push method and device | |
| US9537786B2 (en) | Method, device, and system for information processing based on distributed buses | |
| US20150213134A1 (en) | Data query method and system and storage medium | |
| CN113326155B (en) | Information processing method, device, system and storage medium | |
| US20120072575A1 (en) | Methods and computer program products for aggregating network application performance metrics by process pool | |
| WO2012146026A1 (en) | Method and system for monitoring internet of things | |
| CN112769652B (en) | Node service monitoring method, device, equipment and medium | |
| CN112543222A (en) | Data processing method and device, computer equipment and storage medium | |
| WO2015062228A1 (en) | Method and device for accessing shared memory | |
| CN110661836B (en) | Message routing method, device and system, and storage medium | |
| US9537735B2 (en) | Data collection method, mobile terminal and data storage device | |
| CN105893150B (en) | Interface calling frequency control method and device and interface calling request processing method and device | |
| CN119052310B (en) | TCP connection management method, TCP connection management device, electronic equipment, storage medium and program product | |
| WO2021134766A1 (en) | Method, apparatus and device for determining device state, and storage medium | |
| CN110909030A (en) | Information processing method and server cluster | |
| CN112711606A (en) | Database access method and device, computer equipment and storage medium | |
| CN112104698A (en) | Method for accessing vehicle-mounted terminal to gateway, related equipment and medium | |
| US20160261476A1 (en) | Message system for avoiding processing-performance decline | |
| CN109034768B (en) | Financial reconciliation method, apparatus, computer device and storage medium | |
| CN117729260B (en) | Request sending method, client, electronic device and storage medium | |
| CN1705287A (en) | Communication method between network computer terminal and server | |
| CN104298560A (en) | Load sharing system and load sharing method |
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 |