A network connection management method, computer program product, electronic device and storage medium
By establishing a private protocol connection between the data communication process and the application protocol, and managing long and short connections according to the network connection context data, the problems of low network connection management efficiency and connection ID conflicts are solved, and efficient network connection management is achieved.
Patent Information
- Application Number
- CN202411454564.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-10-17
AI Technical Summary
When managing a large number of network connections, existing technologies are inefficient and prone to lag, with frequent connection ID conflicts.
By establishing a private protocol connection between the data communication process and the application protocol, the connection type is determined according to the network connection context data, and hash tables and linked lists are used to manage long and short connections, and random numbers are generated to avoid conflicts.
Improved network connection management efficiency, reduced lag and connection ID conflicts, and optimized system resource utilization.
Smart Images

Figure CN119276922B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network communication technology, and in particular to a network connection management method, a computer program product, an electronic device, and a storage medium. Background Art
[0002] In network communications and network security systems, multiple processes often need to collaborate to process protocols and data. For example, a data communication engine, an application protocol processing engine, and a virus engine collaborate to complete network data communications or perform virus checks on network content. This collaborative process requires the use of inter-process communication technologies such as shared memory, message queues, and sockets. To achieve high-speed data exchange between processes, shared memory is used to transmit data. Two processes store data in shared memory and transmit shared memory addresses to each other through queues. However, when processing data across large amounts of network connections, processes must manage network connections.
[0003] To solve the problem of managing network connections, the existing technology establishes a queue for each network connection between two processes. When transmitting data between the two processes, the queue and the network connection can be bound together through the context. However, when the number of network connections is too large, multiple queues need to be created, which occupies more shared memory, is inefficient, and is prone to lag.
[0004] Alternatively, a simple communication protocol using a proprietary protocol and a connection ID can be used to establish a proprietary connection between two processes. The connection ID is then bound to the network connection through the connection context. A communication queue is established between the two processes to transmit packets encapsulated by the proprietary protocol. However, in situations such as when the network connection source port is occupied, the random number method is inefficient for a small number of connections, and connection ID value conflicts may occur with a large number of connections. Summary of the Invention
[0005] The purpose of this application is to provide a network connection management method, computer program product, electronic device and storage medium, which can improve the management efficiency of network connections, and can also achieve effective management when the number of network connections is large, without the occurrence of lag and avoidance of connection ID conflicts.
[0006] In a first aspect, an embodiment of the present application provides a method for managing a network connection, the method comprising:
[0007] Get the communication queue between the data communication process and the application protocol;
[0008] Establishing a network connection between the data communication process and the business system to obtain network connection context data;
[0009] Establishing a private protocol connection between the data communication process and the application protocol according to the communication queue and the private protocol;
[0010] Obtaining a connection type of the private protocol connection according to the network connection context data;
[0011] The private protocol connection is managed according to the connection type.
[0012] In the above implementation process, the connection type of the private protocol connection is obtained according to the network connection context data, and then different types of private protocol connections are managed, which can improve the management efficiency of the network connection. When the number of network connections is large, effective management can also be achieved, and it is less likely to cause jamming and avoid connection ID conflicts.
[0013] Furthermore, after the step of establishing a network connection between the data communication process and the business system and obtaining network connection context data, the step further includes:
[0014] A first random number is generated based on the network connection IP address and port of the network connection.
[0015] In the above implementation process, the first random number is generated after the network is connected, which facilitates the subsequent adjustment and weighting of the random number and improves the management efficiency of the random number.
[0016] Furthermore, before the step of obtaining the connection type of the proprietary protocol connection according to the network connection context data, the method further includes:
[0017] Get the connection ID and a linked list node in the available ID linked list;
[0018] storing the connection ID, the linked list node, and the network connection context data in a short connection table, and associating the linked list node with the network connection context data;
[0019] The connection ID is transferred from the available ID chain list to the used ID chain list.
[0020] In the above implementation process, the connection ID, linked list node and network connection context data are stored in the short connection table, which facilitates timely search of the short connection table, saves data search time and improves search efficiency.
[0021] Furthermore, the step of obtaining the connection type of the proprietary protocol connection according to the network connection context data includes:
[0022] Obtaining context data of the private protocol connection according to the network connection context data;
[0023] Obtaining the lifetime of the private protocol connection according to the context data of the private protocol connection;
[0024] If the lifetime is greater than a first time threshold, determining that the private protocol connection is a long connection;
[0025] If the lifetime is greater than or equal to the second time threshold and less than or equal to the third time threshold, it is determined that the proprietary protocol connection is a short connection.
[0026] In the above implementation process, the connection type of the private protocol connection is determined according to the lifetime of the private protocol connection and then managed according to long connection or short connection. This can improve the management efficiency of the network connection, facilitate switching from short connection to long connection, and reduce the consumption of system resources.
[0027] Furthermore, the step of obtaining the connection type of the proprietary protocol connection according to the network connection context data further includes:
[0028] If the private protocol connection is a long connection, the connection ID is transferred to the available ID linked list, and the network connection context data is removed from the short connection table;
[0029] Get a new connection ID.
[0030] In the above implementation process, when the private protocol connection is a long connection, the connection ID is transferred in time and a new connection ID is generated to prevent the used ID list and the short connection table from being occupied for a long time, thereby reducing data redundancy in the storage process.
[0031] Furthermore, the step of managing the private protocol connection according to the connection type includes:
[0032] If the private protocol connection is a persistent connection, check the persistent connection table to see if the new connection ID conflicts.
[0033] If there is a conflict, the first random number is adjusted.
[0034] In the above implementation process, when the private protocol connection is a long connection, it is determined whether the new connection ID conflicts, so as to adjust the random number in time, thereby adjusting the network connection, which can improve the management efficiency of the private protocol connection between processes.
[0035] Furthermore, the step of adjusting the first random number includes:
[0036] Divide the value range of the connection ID into multiple sub-ranges;
[0037] storing each of the sub-ranges and its occupancy counter information as a node in an array;
[0038] generating a second random number;
[0039] Selecting a node with the least number of occupied counters in the array, and obtaining a sub-range corresponding to the node with the least number of occupied counters;
[0040] The first random number is adjusted according to the second random number and the sub-range corresponding to the node with the least number of occupancy counters.
[0041] In the above implementation process, after the value range of the connection ID is re-divided, the first random number is adjusted according to the sub-range, which can reduce the occupation of storage space and further reduce the consumption of resources.
[0042] Furthermore, after the step of adjusting the first random number, the method further includes:
[0043] Determine whether the new connection ID is in use;
[0044] If so, increase the occupancy counter of the node with the smallest occupancy counter by one, and reorder the array;
[0045] If not, the number of the occupancy counter of the node with the least number of occupancy counters is reduced by one, and the array is reordered.
[0046] In the above implementation process, the counter quantity is adjusted in time to facilitate flexible switching of network connections, thereby improving the management efficiency of network connections and avoiding connection ID conflicts.
[0047] In a second aspect, an embodiment of the present application provides a computer program product, which, when running on a computer, enables the computer to execute the method as described in any one of the first aspects.
[0048] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of the first aspects when executing the computer program.
[0049] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which instructions are stored. When the instructions are executed on a computer, the computer executes the method as described in any one of the first aspects.
[0050] In a fifth aspect, an embodiment of the present application further provides a network connection management device, the device comprising:
[0051] An acquisition module is used to obtain the communication queue between the data communication process and the application protocol;
[0052] A connection module, configured to establish a network connection between the data communication process and the business system, and obtain network connection context data;
[0053] An establishing module, configured to establish a private protocol connection between the data communication process and the application protocol according to the communication queue and the private protocol;
[0054] a data acquisition module, configured to obtain a connection type of the private protocol connection according to the network connection context data;
[0055] A management module is used to manage the private protocol connection according to the connection type.
[0056] In the above implementation process, the connection type of the private protocol connection is obtained according to the network connection context data, and then different types of private protocol connections are managed, which can improve the management efficiency of the network connection. When the number of network connections is large, effective management can also be achieved, and it is less likely to cause jamming and avoid connection ID conflicts.
[0057] Other features and advantages of the present disclosure will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by practicing the above-mentioned technology of the present disclosure.
[0058] It can be implemented according to the contents of the specification. The following is a detailed description of the preferred embodiments of the present application with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the range values. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0060] Figure 1 A flowchart of a method for managing network connections provided in an embodiment of the present application;
[0061] Figure 2 A schematic diagram of the structure of a network connection management device provided in an embodiment of the present application;
[0062] Figure 3 A schematic diagram of the structural composition of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0064] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and should not be understood as indicating or implying relative importance.
[0065] The following embodiments are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0066] Example 1
[0067] Figure 1 This is a flow chart of a method for managing network connections provided by an embodiment of the present application. Figure 1 As shown, the method includes:
[0068] S1, obtain the communication queue between the data communication process and the application protocol;
[0069] S2, establish a network connection between the data communication process and the business system, and obtain network connection context data;
[0070] S3, establishing a private protocol connection between the data communication process and the application protocol based on the communication queue and the private protocol;
[0071] S4, obtaining a connection type of the private protocol connection according to the network connection context data;
[0072] S5, manage the private protocol connection according to the connection type.
[0073] In the above implementation process, the connection type of the private protocol connection is obtained according to the network connection context data, and then different types of private protocol connections are managed, which can improve the management efficiency of the network connection. When the number of network connections is large, effective management can also be achieved, and it is less likely to cause jamming and avoid connection ID conflicts.
[0074] Furthermore, after the steps of establishing a network connection between the data communication process and the business system and obtaining network connection context data, the method further includes:
[0075] A first random number is generated based on the network connection IP address and port of the network connection.
[0076] In the above implementation process, the first random number is generated after the network is connected, which facilitates the subsequent adjustment and weighting of the random number and improves the management efficiency of the random number.
[0077] After a new network connection is established, a hash value generated using the network connection IP address and port is weighted to generate a first random number.
[0078] In S3, a communication queue and a private protocol are used to establish a private protocol connection with another process. The other process simultaneously saves the IP address, connection ID and other parts of the network connection context data in the short connection table.
[0079] Furthermore, before the step of obtaining the connection type of the private protocol connection according to the network connection context data, the method further includes:
[0080] Get the connection ID and a linked list node in the available ID linked list;
[0081] Store the connection ID, linked list node and network connection context data in the short connection table, and associate the linked list node with the network connection context data;
[0082] Transfer the connection ID from the available ID list to the used ID list.
[0083] In the above implementation process, the connection ID, linked list node and network connection context data are stored in the short connection table, which facilitates timely search of the short connection table, saves data search time and improves search efficiency.
[0084] Proprietary protocol connections use a field to identify the connection ID. Assume that the field length is 4 bytes and the value range is 0x00 to 0xFF FF FF FF. Each connection ID is associated with a five-tuple of the network connection IP address and port. A data structure is used to store information such as the connection ID to form network connection context data. The connection ID is used as the key to store the network connection context data in a hash table, which is called a connection table.
[0085] The connection ID range R1 to R2 (for example, 0x00 to 0xFFFFF) is allocated for short connections. A short connection hash table, called the short connection table, is used to manage short connections. The connection ID range R3 to R4 (for example, 0x10000 to 0xFF FF FF) is allocated for long connections. A long connection hash table, called the long connection table, is used to manage long connections. The connection ID value range can be adjusted based on the number of connections in the business system and is fixed at system startup.
[0086] Furthermore, S4 includes:
[0087] Obtaining context data of a private protocol connection according to the network connection context data;
[0088] Obtaining the lifetime of the private protocol connection according to the context data of the private protocol connection;
[0089] If the lifetime is greater than the first time threshold, the private protocol connection is determined to be a long connection;
[0090] If the lifetime is greater than or equal to the second time threshold and less than or equal to the third time threshold, the proprietary protocol connection is determined to be a short connection.
[0091] In the above implementation process, the connection type of the private protocol connection is determined according to the lifetime of the private protocol connection and then managed according to long connection or short connection. This can improve the management efficiency of the network connection, facilitate switching from short connection to long connection, and reduce the consumption of system resources.
[0092] When the lifetime T of a private protocol connection is greater than the first time threshold, such a connection is called a long connection; a connection less than the threshold is called a short connection; 2 seconds (second time threshold) ≤ T ≤ 30 seconds (third time threshold).
[0093] When a network connection receives data, it obtains the context data of the proprietary protocol connection based on the network connection context data and calculates the lifetime T of the proprietary protocol connection. If T exceeds a first threshold, the connection is marked as a persistent connection. Alternatively, the lifetime T of each connection in the used ID list is periodically calculated. If T exceeds a first threshold, the connection is marked as a persistent connection.
[0094] Furthermore, S4 also includes:
[0095] If the private protocol connection is a long connection, the connection ID is transferred to the available ID list and the network connection context data is removed from the short connection table;
[0096] Get a new connection ID.
[0097] In the above implementation process, when the private protocol connection is a long connection, the connection ID is transferred in time and a new connection ID is generated to prevent the used ID list and the short connection table from being occupied for a long time, thereby reducing data redundancy in the storage process.
[0098] The connection IDs of unoccupied short connections are stored in a linked list called the Available ID Link List, which can accommodate 0xFFFFF nodes. The occupied connection IDs are stored in a linked list called the Used ID Link List.
[0099] After a new network connection is established, a linked list node and connection ID are obtained from the available ID linked list, and stored in the short connection table together with the network connection context data. The linked list node is associated with the network connection context data, and the connection ID node is transferred from the available ID linked list to the used ID linked list.
[0100] The connection ID and network connection context data are removed from the used ID list and short connection table. A new connection ID is obtained using the persistent connection management method. The other party is notified via a private protocol to update the old connection ID to the new one. After the update, the network connection context data is released and the old connection ID is stored in the available ID list.
[0101] When there is no connection ID available in the available ID list, the connection ID will be obtained according to the long connection management method.
[0102] When closing a network connection, the connection ID is transferred from the used ID list to the available ID list, the network connection context data is released in the short connection table, and another process is notified through a private protocol to release related resources.
[0103] Furthermore, S5 includes:
[0104] If the private protocol connection is a persistent connection, check the persistent connection table to see if the new connection ID conflicts.
[0105] If there is a conflict, the first random number is adjusted.
[0106] In the above implementation process, when the private protocol connection is a long connection, it is determined whether the new connection ID conflicts, so as to adjust the random number in time, thereby adjusting the network connection, which can improve the management efficiency of the private protocol connection between processes.
[0107] The new connection ID is checked in the long connection table to see if it conflicts. If so, the query is terminated. If it fails, the new connection ID is requested from the available ID list. If it still does not meet the requirements, the new connection ID is generated again.
[0108] Furthermore, the step of adjusting the first random number includes:
[0109] Divide the value range of the connection ID into multiple sub-ranges;
[0110] Store each subrange and its occupancy counter information as a node in an array;
[0111] generating a second random number;
[0112] Select the node with the least number of occupied counters in the array, and obtain the sub-range corresponding to the node with the least number of occupied counters;
[0113] The first random number is adjusted according to the second random number and the sub-range corresponding to the node with the least number of occupied counters.
[0114] In the above implementation process, after the value range of the connection ID is re-divided, the first random number is adjusted according to the sub-range, which can reduce the occupation of storage space and further reduce the consumption of resources.
[0115] Since long connections occupy some random numbers for a long time, the probability of random number conflicts within a certain range increases. In order to reduce the probability, the embodiment of the present application divides the connection ID value range into N value ranges R1~R2, R3~R4... (referred to as sub-ranges) in units of n, and stores each sub-range and occupancy counter and other information as a node in an array, and sorts them from small to large according to the occupancy counter.
[0116] Generate a random number rand3 (the second random number), select the node with the minimum value of the occupation counter, assuming the sub-range is R5 to R6, and the adjusted random number = (R5 + rand3 mod (R6 - R5 + 1) + rand3 / R6) mod (R6 - R5 + 1).
[0117] Furthermore, after the step of adjusting the first random number, the method further includes:
[0118] Determine whether the new connection ID is in use;
[0119] If so, increase the occupancy counter of the node with the smallest occupancy counter by one and reorder the array;
[0120] If not, the occupancy counter of the node with the smallest occupancy counter is reduced by one, and the array is reordered.
[0121] In the above implementation process, the counter quantity is adjusted in time to facilitate flexible switching of network connections, thereby improving the management efficiency of network connections and avoiding connection ID conflicts.
[0122] When using a connection ID, the node occupancy counter is incremented by 1, and the array is reordered. When not using a connection ID, the node occupancy counter is decremented by 1, and the array is reordered. Since the array needs to be sorted every time, the embodiment of the present application controls the array length to within a single digit.
[0123] Exemplarily, when the data communication process and the application protocol processing process are started, a communication queue is established, a random number is generated according to the random number mechanism of the present application, the data communication process establishes a network connection with the external business system according to the strategy, and the data communication process establishes a private protocol connection with the application protocol processing process through the communication queue and the private protocol. When establishing a connection, the data communication process gives priority to using the available ID linked list, obtains the connection ID, and establishes an association between the private protocol connection and the network connection, which is stored in the short connection table with the connection ID as the key.
[0124] The two parties communicate through a private protocol and a communication queue. When the lifetime of this connection ID exceeds a first threshold, the data communication process adopts a long connection management method, obtains a weighted random number as the connection ID, and checks whether the connection ID conflicts. If there is a conflict, a new random number is selected and the new ID is notified to the application protocol processing process through a private protocol. The application protocol processing process synchronously updates the connection ID.
[0125] After completing data transmission and closing the network connection, the data communication process closes the network connection, private protocol connection, releases the connection ID and other related resources, and the application protocol processing process also synchronously executes the shutdown-related functions.
[0126] The short and long connection management method for private protocol connections in the embodiments of the present application improves the efficiency of private protocol connection management between processes and consumes fewer system resources. The present application manages connections by associating private protocol connection IDs with network connections, and adopts hash tables, linked lists, and connection ID classification management of long and short connections and short connections to implement private protocol connection management, thereby improving the efficiency of private protocol connection management between processes and consuming fewer system resources.
[0127] Example 2
[0128] An embodiment of the present application provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute any method of the first embodiment.
[0129] Example 3
[0130] In order to execute the method corresponding to the above embodiment 1 to achieve the corresponding functions and technical effects, a network connection management device is provided below, such as Figure 2 As shown, the device includes:
[0131] Acquisition module 1, used to obtain the communication queue between the data communication process and the application protocol;
[0132] Connection module 2, used to establish a network connection between the data communication process and the business system and obtain network connection context data;
[0133] Establishing module 3, for establishing a private protocol connection between the data communication process and the application protocol based on the communication queue and the private protocol;
[0134] A data acquisition module 4 is configured to obtain a connection type of a private protocol connection according to the network connection context data;
[0135] The management module 5 is used to manage the private protocol connection according to the connection type.
[0136] In the above implementation process, the connection type of the private protocol connection is obtained according to the network connection context data, and then different types of private protocol connections are managed, which can improve the management efficiency of the network connection. When the number of network connections is large, effective management can also be achieved, and it is less likely to cause jamming and avoid connection ID conflicts.
[0137] Furthermore, the device also includes a generating module, which is used to:
[0138] A first random number is generated based on the network connection IP address and port of the network connection.
[0139] In the above implementation process, the first random number is generated after the network is connected, which facilitates the subsequent adjustment and weighting of the random number and improves the management efficiency of the random number.
[0140] Furthermore, the data acquisition module 4 is also used for:
[0141] Get the connection ID and a linked list node in the available ID linked list;
[0142] Store the connection ID, linked list node and network connection context data in the short connection table, and associate the linked list node with the network connection context data;
[0143] Transfer the connection ID from the available ID list to the used ID list.
[0144] In the above implementation process, the connection ID, linked list node and network connection context data are stored in the short connection table, which facilitates timely search of the short connection table, saves data search time and improves search efficiency.
[0145] Furthermore, the data acquisition module 4 is also used for:
[0146] Obtaining context data of a private protocol connection according to the network connection context data;
[0147] Obtaining the lifetime of the private protocol connection according to the context data of the private protocol connection;
[0148] If the lifetime is greater than the first time threshold, the private protocol connection is determined to be a long connection;
[0149] If the lifetime is greater than or equal to the second time threshold and less than or equal to the third time threshold, the proprietary protocol connection is determined to be a short connection.
[0150] In the above implementation process, the connection type of the private protocol connection is determined according to the lifetime of the private protocol connection and then managed according to long connection or short connection. This can improve the management efficiency of the network connection, facilitate switching from short connection to long connection, and reduce the consumption of system resources.
[0151] Furthermore, the data acquisition module 4 is also used for:
[0152] If the private protocol connection is a long connection, the connection ID is transferred to the available ID list and the network connection context data is removed from the short connection table;
[0153] Get a new connection ID.
[0154] In the above implementation process, when the private protocol connection is a long connection, the connection ID is transferred in time and a new connection ID is generated to prevent the used ID list and the short connection table from being occupied for a long time, thereby reducing data redundancy in the storage process.
[0155] Furthermore, the management module 5 is also used to:
[0156] If the private protocol connection is a persistent connection, check the persistent connection table to see if the new connection ID conflicts.
[0157] If there is a conflict, the first random number is adjusted.
[0158] In the above implementation process, when the private protocol connection is a long connection, it is determined whether the new connection ID conflicts, so as to adjust the random number in time, thereby adjusting the network connection, which can improve the management efficiency of the private protocol connection between processes.
[0159] Furthermore, the management module 5 is also used to:
[0160] Divide the value range of the connection ID into multiple sub-ranges;
[0161] Store each subrange and its occupancy counter information as a node in an array;
[0162] generating a second random number;
[0163] Select the node with the least number of occupied counters in the array, and obtain the sub-range corresponding to the node with the least number of occupied counters;
[0164] The first random number is adjusted according to the second random number and the sub-range corresponding to the node with the least number of occupied counters.
[0165] In the above implementation process, after the value range of the connection ID is re-divided, the first random number is adjusted according to the sub-range, which can reduce the occupation of storage space and further reduce the consumption of resources.
[0166] Furthermore, the management module 5 is also used to:
[0167] Determine whether the new connection ID is in use;
[0168] If so, increase the occupancy counter of the node with the smallest occupancy counter by one and reorder the array;
[0169] If not, the occupancy counter of the node with the smallest occupancy counter is reduced by one, and the array is reordered.
[0170] In the above implementation process, the counter quantity is adjusted in time to facilitate flexible switching of network connections, thereby improving the management efficiency of network connections and avoiding connection ID conflicts.
[0171] The network connection management device can implement the method of the embodiment 1. The options in the embodiment 1 are also applicable to this embodiment and will not be described in detail here.
[0172] The rest of the contents of the embodiment of this application can refer to the contents of the above-mentioned embodiment 1, and will not be repeated in this embodiment.
[0173] Example 4
[0174] An embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the network connection management method of embodiment 1.
[0175] Optionally, the above-mentioned electronic device may be a server.
[0176] See Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include a processor 31, a communication interface 32, a memory 33, and at least one communication bus 34. The communication bus 34 is used to enable direct communication between these components. The communication interface 32 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The processor 31 may be an integrated circuit chip with signal processing capabilities.
[0177] The processor 31 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. A general-purpose processor can be a microprocessor, or the processor 31 can also be any conventional processor.
[0178] The memory 33 may be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory 33 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 31, the device can perform the above-mentioned operations. Figure 1 The various steps involved in the method embodiment.
[0179] Optionally, the electronic device may further include a memory controller and an input / output unit. The memory 33, memory controller, processor 31, peripheral interface, and input / output unit are electrically connected to each other, directly or indirectly, to enable data transmission or interaction. For example, these components may be electrically connected to each other via a communication bus 34. The processor 31 is configured to execute executable modules stored in the memory 33, such as software function modules or computer programs included in the device.
[0180] The input and output unit is used to provide users with the ability to create tasks and to create optional start time periods or preset execution times for the tasks to enable interaction between the user and the server. The input and output unit can be, but is not limited to, a mouse and keyboard.
[0181] I understand. Figure 3 The structure shown is only for illustration, and the electronic device may also include Figure 3 More or fewer components than shown, or with Figure 3 Different configurations shown. Figure 3 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0182] In addition, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the network connection management method of the first embodiment.
[0183] An embodiment of the present application further provides a computer program product, which, when running on a computer, enables the computer to execute the method described in the method embodiment.
[0184] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a portion of code, and the module, program segment or a portion of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based device that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions.
[0185] In addition, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0186] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
[0187] The foregoing is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included within the scope of protection of the present application. It should be noted that similar numbers and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined or explained in subsequent figures.
[0188] The above descriptions are merely specific embodiments of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
[0189] It should be noted that the relative terms, such as first and second, and the like, are used herein only to distinguish one entity or action from another, and do not necessarily require or imply any actual such relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by an "includes a..." statement does not exclude the existence of additional identical elements in the process, method, article, or apparatus that includes the element.
Claims
1. A method for managing a network connection, characterized in that: The method comprises: Get the communication queue between the data communication process and the application protocol; Establishing a network connection between the data communication process and the business system to obtain network connection context data; Establishing a private protocol connection between the data communication process and the application protocol according to the communication queue and the private protocol; Obtaining a connection type of the private protocol connection according to the network connection context data; The private protocol connection is managed according to the connection type.
2. The method for managing network connections according to claim 1, wherein: After the steps of establishing a network connection between the data communication process and the business system and obtaining network connection context data, the method further includes: A first random number is generated based on the network connection IP address and port of the network connection.
3. The method for managing network connections according to claim 2, wherein: Before the step of obtaining the connection type of the private protocol connection according to the network connection context data, the method further includes: Get the connection ID and a linked list node in the available ID linked list; storing the connection ID, the linked list node, and the network connection context data in a short connection table, and associating the linked list node with the network connection context data; The connection ID is transferred from the available ID chain list to the used ID chain list.
4. The method for managing network connections according to claim 3, wherein: The step of obtaining the connection type of the proprietary protocol connection according to the network connection context data includes: Obtaining context data of the private protocol connection according to the network connection context data; Obtaining the lifetime of the private protocol connection according to the context data of the private protocol connection; If the lifetime is greater than a first time threshold, determining that the private protocol connection is a long connection; If the lifetime is greater than or equal to the second time threshold and less than or equal to the third time threshold, it is determined that the proprietary protocol connection is a short connection.
5. The method for managing network connections according to claim 4, wherein: The step of obtaining the connection type of the private protocol connection according to the network connection context data further includes: If the private protocol connection is a long connection, the connection ID is transferred to the available ID linked list, and the network connection context data is removed from the short connection table; Get a new connection ID.
6. The method for managing network connections according to claim 5, wherein: The step of managing the private protocol connection according to the connection type includes: If the private protocol connection is a persistent connection, check the persistent connection table to see if the new connection ID conflicts. If there is a conflict, the first random number is adjusted.
7. The method for managing network connections according to claim 6, wherein: The step of adjusting the first random number includes: Divide the value range of the connection ID into multiple sub-ranges; storing each of the sub-ranges and its occupancy counter information as a node in an array; generating a second random number; Selecting a node with the least number of occupied counters in the array, and obtaining a sub-range corresponding to the node with the least number of occupied counters; The first random number is adjusted according to the second random number and the sub-range corresponding to the node with the least number of occupancy counters.
8. The method for managing network connections according to claim 7, wherein: After the step of adjusting the first random number, the method further includes: Determine whether the new connection ID is in use; If so, increase the occupancy counter of the node with the smallest occupancy counter by one, and reorder the array; If not, the number of the occupancy counter of the node with the least number of occupancy counters is reduced by one, and the array is reordered.
9. A computer program product, characterized in that When the computer program product is run on a computer, the computer is caused to perform the method according to any one of claims 1 to 8.
10. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the network connection management method according to any one of claims 1 to 8.
11. A storage medium, characterized in that: The device stores a computer program, which, when executed by a processor, implements the network connection management method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Processing method, terminal and network element
CN110636587A
Data processing method and system based on session connection
CN115208941A