Network connection management method, computer program product, electronic equipment and storage medium
Through the method of managing network connections, the types of private protocol connections are obtained and managed according to the network connection context data, and random numbers are generated to avoid connection ID conflicts, which solves the problem of low efficiency and connection ID conflicts when the network connection is large, and achieves high efficiency network connection management.
Patent Information
- Application Number
- CN202411454564.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-10-17
AI Technical Summary
When managing network connections, the efficiency is low when the number of network connections is large, and it is prone to lag, and there is a problem of connection ID conflict.
By obtaining the communication queue between the data communication process and the application protocol, establishing a network connection, obtaining the connection type of the private protocol connection based on the network connection context data, and managing it, generating random numbers to avoid connection ID conflicts, and dividing the value of the connection ID Range to reduce resource consumption.
Improve the management efficiency of network connections, avoid lag and connection ID conflicts, and optimize the use of system resources.
Smart Images

Figure CN119276922A_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 communication and network security systems, it is usually necessary for multiple processes to collaboratively process protocols and data. For example, the data communication engine, application protocol processing engine, and virus engine collaborate to complete network data communication or perform virus checks on network content. In the collaborative process, inter-process communication technologies such as shared memory, message queues, and Sockets are required. In order to achieve high-speed data exchange between processes, shared memory is required to transmit data. The two processes store the data in the shared memory together and transmit the shared memory address to each other through queues. However, when processing a large amount of data connected to the network, the process needs to manage the network connection well.
[0003] In order to solve the problem of managing network connections, the existing technology establishes a queue for each network connection of 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 prone to jamming.
[0004] Alternatively, a simple communication protocol using a private protocol and connection ID is used to establish a private protocol connection between two processes, and the connection ID is bound to the network connection through the connection context. A communication queue is established between the two processes to transmit data packets encapsulated by the private protocol. However, in similar situations where the source port of the network connection is occupied, if the number of connections is small, the random number method is not efficient, and when the number of connections is large, there is a conflict in the connection ID value. 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 prone to lag and avoid 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. This 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 have 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 private 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 linked list to the used ID linked 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 private 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 private 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 private 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 avoid the used ID list and the short connection table being occupied for a long time and reduce 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 whether the new connection ID conflicts with the persistent connection table;
[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 occupied 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, the number of occupancy counters of the node with the least number of occupancy counters is increased by one, and the array is reordered;
[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 the 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, used to acquire the communication queue between the data communication process and the application protocol;
[0052] A connection module, used to establish a network connection between the data communication process and the business system, and obtain network connection context data;
[0053] An establishing module, used for establishing 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, used for acquiring 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. This 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 have 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 implementing the above-mentioned technology of the present disclosure.
[0058] And 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 drawings required for use in the embodiments of the present application will be briefly introduced below. 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 related drawings can be obtained based on these drawings without paying any 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, so once an item is defined in one drawing, it does not need to be further defined and 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 cannot be understood as indicating or implying relative importance.
[0065] The specific implementation methods of the present application are further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present application, but are not used to limit the scope of the present application.
[0066] Embodiment 1
[0067] Figure 1 is a flow chart of a method for managing network connections provided in an embodiment of the present application, such as 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 according to 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. This 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 have jamming and avoid connection ID conflicts.
[0074] 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 method further includes:
[0075] A first random number is generated based on a network connection IP address and a 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 and processed into 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, and the other process synchronously 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] Storing the connection ID, linked list node and network connection context data in the short connection table, and associating 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] The private protocol connection uses 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 the 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 to short connections, and a short connection hash table is set to manage short connections, which is called a short connection table. The connection ID range R3 to R4 (for example, 0x10000 to 0xFF FF FF FF) is allocated to long connections, and a long connection hash table is set to manage long connections, which is called a long connection table. The connection ID value range can be adjusted according to the changes in the number of connections in the business system, and the value range is fixed when the system is started.
[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, it is determined that the private protocol connection is 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 the private protocol connection is greater than the first time threshold, such a connection is called a long connection, and a connection less than the threshold is called a short connection, 2 seconds (second time threshold) ≤ T ≤ 30 seconds (third time threshold).
[0093] When the network connection receives data, the context data of the private protocol connection is obtained according to the network connection context data, and the lifetime T of the private protocol connection is calculated. If T exceeds the first threshold, the connection is marked as a long connection. Alternatively, the lifetime T of each connection in the used ID chain list is calculated periodically, and if T exceeds the first threshold, the connection is marked as a long 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 avoid the used ID list and the short connection table being occupied for a long time and reduce 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 a 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 list, a new connection ID is obtained using the long connection management method, and the other party is notified through a private protocol to update the old connection ID to the new connection ID. 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 a network connection is closed, 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] Check the long connection table for new connection ID conflicts. If conflicts occur, terminate the query. If failed, try to apply for connection ID from available ID list. If still does not meet the requirements, continue to try to generate random numbers.
[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 sub-range 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 (second random number), select the node with the minimum value of the occupied counter, assuming the sub-range is R5~R6, 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 least occupancy counter by one, and reorder the array;
[0120] If not, the number of occupied counters of the node with the smallest number of occupied counters is reduced by one, and the array is reordered.
[0121] In the above implementation process, the counter quantity is adjusted in time to facilitate the flexible switching of network connections, thereby improving the management efficiency of network connections and avoiding connection ID conflicts.
[0122] When the connection ID is used, the node occupancy counter is increased by 1, and the array is reordered. When the connection ID is not used, the node occupancy counter is decreased by 1, and the array is reordered. Since the array needs to be sorted each time, the embodiment of the present application controls the array length 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 policy, the data communication process establishes a private protocol connection with the application protocol processing process through the communication queue and the private protocol, and when establishing the 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 executes the closing related functions synchronously.
[0126] The short connection and long connection management method of the private protocol connection of the embodiment of the present application improves the efficiency of private protocol connection management between processes and consumes less system resources. The present application manages the connection by associating the private protocol connection ID with the network connection, adopts the long and short connections and short connections managed by the hash table, linked list and connection ID classification, realizes the private protocol connection management, improves the efficiency of private protocol connection management between processes, and consumes less system resources.
[0127] Embodiment 2
[0128] An embodiment of the present application provides a computer program product. When the computer program product is run on a computer, the computer executes any method of the first embodiment.
[0129] Embodiment 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 comprises:
[0131] Acquisition module 1, used to acquire 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, used for establishing a private protocol connection between the data communication process and the application protocol according to the communication queue and the private protocol;
[0134] A data acquisition module 4, used for acquiring a connection type of a private protocol connection according to 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. This 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 have 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 a network connection IP address and a 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] Storing the connection ID, linked list node and network connection context data in the short connection table, and associating 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, it is determined that the private protocol connection is 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 avoid the used ID list and the short connection table being occupied for a long time and reduce data redundancy in the storage process.
[0155] Furthermore, the management module 5 is also used for:
[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 for:
[0160] Divide the value range of the connection ID into multiple sub-ranges;
[0161] Store each sub-range 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 for:
[0167] Determine whether the new connection ID is in use;
[0168] If so, increase the occupancy counter of the node with the least occupancy counter by one, and reorder the array;
[0169] If not, the number of occupied counters of the node with the smallest number of occupied counters is reduced by one, and the array is reordered.
[0170] In the above implementation process, the counter quantity is adjusted in time to facilitate the flexible switching of network connections, thereby improving the management efficiency of network connections and avoiding connection ID conflicts.
[0171] The above-mentioned network connection management device can implement the method of the above-mentioned embodiment 1. The options in the above-mentioned embodiment 1 are also applicable to this embodiment and will not be described in detail here.
[0172] The rest of the contents of the embodiments of the present application can refer to the contents of the above-mentioned embodiment 1, and will not be repeated in this embodiment.
[0173] Embodiment 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 the first embodiment.
[0175] Optionally, the above-mentioned electronic device may be a server.
[0176] See also Figure 3 , Figure 3 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 realize direct connection and 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 devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor 31 can also be any conventional processor, etc.
[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 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 execute the above-mentioned Figure 1 The method embodiment involves various steps.
[0179] Optionally, the electronic device may further include a storage controller and an input / output unit. The memory 33, the storage controller, the processor 31, the peripheral interface, and the input / output unit are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components may be electrically connected to each other via a communication bus 34. The processor 31 is used 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 task creation and to create an optional time period or preset execution time for the task to enable interaction between the user and the server. The input and output unit can be, but is not limited to, a mouse and a keyboard.
[0181] Understandably, Figure 3 The structure shown is for illustration only. The electronic device may also include Figure 3 More or fewer components as shown, or with Figure 3 Different configurations are 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] The embodiment of the present application also 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 several embodiments provided in the present 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 schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to 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 part of a code, and the module, a program segment or a part of a 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 a different order from the order 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 the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented with a dedicated hardware-based device that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0185] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may 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 can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.
[0187] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0188] The above is only a specific implementation of the present application, but the protection range of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical range disclosed in the present application, which should be included in the protection range of the present application. Therefore, the protection range of the present application should be based on the protection range of the claims.
[0189] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for managing network connections, 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 connection according to claim 1, characterized in that: After the step 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 connection according to claim 2, characterized in that: 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 linked list to the used ID linked list.
4. The method for managing network connection according to claim 3, characterized in that: The step of obtaining the connection type of the private protocol connection according to the network connection context data comprises: 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 private protocol connection is a short connection.
5. The method for managing network connection according to claim 4, characterized in that: 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 connection according to claim 5, characterized in that: The step of managing the private protocol connection according to the connection type includes: If the private protocol connection is a persistent connection, check whether the new connection ID conflicts with the persistent connection table; If there is a conflict, the first random number is adjusted.
7. The method for managing network connection according to claim 6, characterized in that: 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 occupied counters.
8. The method for managing network connection according to claim 7, characterized in that: After the step of adjusting the first random number, the method further includes: Determine whether the new connection ID is in use; If so, the number of occupancy counters of the node with the least number of occupancy counters is increased by one, and the array is reordered; 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 executed on a computer, the computer is enabled 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
Systems and Methods of Providing Server Initiated Connections on a Virtual Private Network
US20080043760A1