Network card processing method, device, electronic equipment and storage medium
By regularly reading network card information and performing reconnection operations, the problem of delay in network card status detection in the existing technology is solved, timely network card status monitoring and automatic recovery are achieved, and network card status monitoring efficiency is improved.
Patent Information
- Application Number
- CN202010486096.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-01
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2040-06-01
AI Technical Summary
The existing technology cannot promptly identify the status of the network card, resulting in delayed detection of the network card status and affecting the operation of computer equipment.
By reading network card information regularly, confirm the available network card, and add the offline network card to the reconnection queue, perform the reconnection operation until the reconnection threshold is successfully or the reconnection threshold is stopped.
It realizes timely detection of network card status, reduces unnecessary detection, automatically restores offline network card, and improves network card status monitoring and recovery efficiency.
Smart Images

Figure CN111885097B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a network card processing method, device, electronic equipment and storage medium. Background Art
[0002] A network card is a modem that can be inserted into a computer or connected to a computer by wire. It can access wireless cellular data networks such as 2G / 3G / 4G through a modem device, so that the computer device can connect to the Internet. Multiple network cards can be inserted into a computer at the same time to aggregate the transmission bandwidth of multiple cards. For example, if a network card has a bandwidth of 5MB, two network cards can be aggregated to achieve a bandwidth of 10MB.
[0003] The status of the network card affects the operation of computer equipment, so timely knowing the status of the network card is of vital importance. At present, the detection of the network card status is usually achieved through the ping technology or the SNMP (Simple Network Management Protocol) technology. However, these technologies have a large delay and cannot timely know the status of the network card. Summary of the invention
[0004] In view of the above problems, embodiments of the present invention are proposed to provide a network card processing method, device, electronic device and storage medium that overcome the above problems or at least partially solve the above problems.
[0005] In a first aspect, an embodiment of the present invention discloses a network card processing method, the method comprising:
[0006] Read the network card information of each network card at regular intervals, and determine the available network card according to the network card information;
[0007] Regularly detect the status of the available network cards, and use the available network cards in an offline state as network cards to be reconnected and add them to a reconnection queue;
[0008] Performing a reconnection operation on each network card to be reconnected in the reconnection queue;
[0009] The network card that successfully reconnects is deleted from the reconnection queue.
[0010] Optionally, the timed detection of the state of the available network card includes: establishing a TCP connection between the available network card and a server; based on the TCP connection, starting a heartbeat thread between the available network card and the server, and timed detection of the state of the available network card through the heartbeat thread.
[0011] Optionally, after adding the available network card in the offline state as the network card to be reconnected to the reconnection queue, it also includes: disconnecting the TCP connection between the available network card in the offline state and the server, and closing the heartbeat thread between the available network card in the offline state and the server.
[0012] Optionally, after determining the available network card based on the network card information, it also includes: determining whether there is a reduced available network card; when there is a reduced available network card, if there is a heartbeat thread between the reduced available network card and the server, disconnecting the TCP connection between the reduced available network card and the server, and closing the heartbeat thread between the reduced available network card and the server; if the reduced available network card exists in the reconnection queue, deleting the reduced available network card from the reconnection queue.
[0013] Optionally, after performing the reconnection operation on each network card to be reconnected in the reconnection queue, it also includes: for the network card that failed to reconnect, if the number of reconnections of the network card that failed to reconnect reaches a preset threshold, stopping the reconnection operation on the network card that failed to reconnect, and displaying network card abnormality prompt information.
[0014] Optionally, the periodic reading of network card information of each network card and determining the available network cards based on the network card information includes: starting a first thread, periodically reading the network card information of each network card through the first thread, and determining the available network cards based on the network card information; performing a reconnection operation on each network card to be reconnected in the reconnection queue includes: starting a second thread, and performing a reconnection operation on each network card to be reconnected in the reconnection queue through the second thread.
[0015] Optionally, reading the network card information of each network card includes: calling a network card information reading function in a system bottom layer function to read the network card information of each network card.
[0016] Optionally, the network card information includes a speed and a working state of the network card; and determining the available network card according to the network card information includes: determining a network card whose speed is greater than or equal to zero and whose working state is a startup state as an available network card.
[0017] Optionally, performing a reconnection operation on each network card to be reconnected in the reconnection queue includes: establishing a TCP connection between the network card to be reconnected and a server; and starting a heartbeat thread between the network card to be reconnected and the server based on the TCP connection.
[0018] In a second aspect, an embodiment of the present invention discloses a network card processing device, the device comprising:
[0019] A first determination module, used for periodically reading the network card information of each network card, and determining an available network card according to the network card information;
[0020] A detection module, used for periodically detecting the status of the available network cards, and adding the available network cards in an offline state as network cards to be reconnected to a reconnection queue;
[0021] A reconnection module, used for performing a reconnection operation on each network card to be reconnected in the reconnection queue;
[0022] The first deleting module is used to delete the network card that has successfully reconnected from the reconnection queue.
[0023] Optionally, the detection module includes: a first establishment unit, used to establish a TCP connection between the available network card and the server; a thread detection unit, used to start a heartbeat thread between the available network card and the server based on the TCP connection, and periodically detect the status of the available network card through the heartbeat thread.
[0024] Optionally, the device also includes: a first closing module, which is used to disconnect the TCP connection between the available network card in the offline state and the server after the detection module adds the available network card in the offline state as the network card to be reconnected to the reconnection queue, and close the heartbeat thread between the available network card in the offline state and the server.
[0025] Optionally, the device also includes: a second determination module, used to determine whether there is a reduced available network card after the first determination module determines the available network card based on the network card information; a second closing module, used to disconnect the TCP connection between the reduced available network card and the server and close the heartbeat thread between the reduced available network card and the server when there is a reduced available network card, if there is a heartbeat thread between the reduced available network card and the server; a second deletion module, used to delete the reduced available network card from the reconnection queue when there is a reduced available network card in the reconnection queue.
[0026] Optionally, the device further includes: a failure processing module, for stopping the reconnection operation on the network card that failed to reconnect if the number of reconnections of the network card that failed to reconnect reaches a preset threshold, and displaying network card abnormality prompt information.
[0027] Optionally, the first determination module is specifically used to start a first thread, and periodically read the network card information of each network card through the first thread, and determine the available network cards based on the network card information; the reconnection module is specifically used to start a second thread, and perform a reconnection operation on each network card to be reconnected in the reconnection queue through the second thread.
[0028] Optionally, the first determination module includes: an information reading unit, configured to call a network card information reading function in a system bottom layer function to read the network card information of each network card.
[0029] Optionally, the network card information includes the speed and working status of the network card; the first determination module includes: a network card determination unit, used to determine a network card whose speed is greater than or equal to zero and whose working status is a startup state as an available network card.
[0030] Optionally, the reconnection module includes: a second establishing unit, used to establish a TCP connection between the network card to be reconnected and the server; and a thread starting unit, used to start a heartbeat thread between the network card to be reconnected and the server based on the TCP connection.
[0031] In a third aspect, an embodiment of the present invention discloses an electronic device, comprising: one or more processors; and one or more machine-readable media having instructions stored thereon; when the instructions are executed by the one or more processors, the processors execute the network card processing method as described in any one of the above items.
[0032] In a fourth aspect, an embodiment of the present invention discloses a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the network card processing method as described in any one of the above items.
[0033] In the embodiment of the present invention, the available network cards can be determined by regularly reading the network card information, and the status of the available network cards is regularly detected. On the one hand, unnecessary detection of unavailable network cards is avoided, and the number of detected network cards is reduced; on the other hand, the network card status can be known more timely through regular detection. By adding the available network cards in the offline state as the network cards to be reconnected to the reconnection queue, and performing the reconnection operation on each network card to be reconnected in the reconnection queue, and deleting the network card that has been successfully reconnected from the reconnection queue, it is possible to automatically reconnect and restore the available network cards in the offline state. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a step flow chart of a network card processing method according to the first embodiment of the present invention.
[0035] Figure 2 It is a step flow chart of a network card processing method according to the second embodiment of the present invention.
[0036] Figure 3 It is a structural block diagram of a network card processing device according to the third embodiment of the present invention.
[0037] Figure 4 It is a structural block diagram of a network card processing device according to a fourth embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0039] Embodiment 1
[0040] Reference Figure 1 , shows a flow chart of the steps of a network card processing method according to the first embodiment of the present invention. The network card processing method according to the embodiment of the present invention can be applied to any computer device equipped with a network card.
[0041] like Figure 1 As shown, the network card processing method may include the following steps:
[0042] Step 101, regularly reading the network card information of each network card, and determining the available network card according to the network card information.
[0043] The computer device system stores the network card information of each inserted network card, and the embodiment of the present invention periodically reads the network card information of each network card stored in the system. For the specific timing time, any applicable value can be set according to the actual situation, for example, the network card information can be read every 5s, 8s, 10s, 15s, etc., and the embodiment of the present invention does not limit this.
[0044] The network card information may include the network card identification, IP (Internet Protocol, a protocol for interconnecting networks) address, speed, working status, etc. Based on the network card information of the network card, it can be determined whether the network card is an available network card. The specific determination method will be described in detail in the following embodiment 2.
[0045] Step 102: regularly detect the status of the available network cards, and use the available network cards in the offline state as network cards to be reconnected and add them to the reconnection queue.
[0046] The status of the network card includes online status and offline status. Since the status of the network card may change during operation, the status of the available network card can be detected regularly to determine whether the available network card is online or offline. There is no need to detect the status of the unavailable network card.
[0047] For the available network card detected to be in an offline state, the available network card in the offline state can be added to the reconnection queue so as to perform a reconnection operation on it later. For the available network card detected to be in an online state, no other processing is performed, and the state of the available network card in the online state continues to be detected regularly.
[0048] Step 103: perform a reconnection operation on each network card to be reconnected in the reconnection queue.
[0049] Step 104: Delete the network card that has successfully reconnected from the reconnection queue.
[0050] Perform reconnection operations on each network card to be reconnected in the reconnection queue to reconnect and restore it to the server. If a network card to be reconnected successfully reconnects, the successfully reconnected network card will be deleted from the reconnection queue and will not be reconnected. If a network card to be reconnected fails to reconnect, continue to reconnect the successfully reconnected network card.
[0051] In the embodiment of the present invention, the available network cards can be determined by regularly reading the network card information, and the status of the available network cards is regularly detected. On the one hand, unnecessary detection of unavailable network cards is avoided, and the number of detected network cards is reduced; on the other hand, the network card status can be known more timely through regular detection. By adding the available network cards in the offline state as the network cards to be reconnected to the reconnection queue, and performing the reconnection operation on each network card to be reconnected in the reconnection queue, and deleting the network card that has been successfully reconnected from the reconnection queue, it is possible to automatically reconnect and restore the available network cards in the offline state.
[0052] Embodiment 2
[0053] Reference Figure 2 , shows a step flow chart of a network card processing method according to embodiment 2 of the present invention.
[0054] like Figure 2 As shown, the network card processing method may include the following steps:
[0055] Step 201, start the program.
[0056] In the program startup phase, the first thread and the second thread can be started. The first thread executes the following steps 202 to 214. The second thread executes the following steps 215 to 222. The first thread and the second thread can be executed in parallel to save time and improve processing efficiency.
[0057] Step 202: Start the first thread.
[0058] Step 203, periodically read the network card information of each network card to determine the available network cards.
[0059] The first thread periodically reads the network card information of each network card to determine the available network card. For example, the network card information can be read once every 5 seconds, 10 seconds, 15 seconds, etc.
[0060] In an optional implementation, a network card information reading function in the system bottom layer function (such as GetAll Network Interfaces function) can be called to read the network card information of each network card in the system. The network card information may include the network card identification, IP address, speed, working status, etc. By calling the system bottom layer function to read the network card information, the processing process is simpler and the read network card information is more accurate.
[0061] For a network card, it is possible to determine whether the network card is an available network card based on the network card information of the network card. In implementation, a network card whose speed is greater than or equal to zero and whose operating status is in the startup state can be determined as an available network card. If the speed (Speed) of the network card is less than 0, it means that the network card speed is a negative value and the network card is unavailable. If the operating status (Operational Status) of the network card is in the startup (UP) state, it means that the network interface is running and data packets can be transmitted. If the operating status of the network card is not in the startup state, it means that the network card is unavailable. Therefore, the network cards whose Speed attribute is less than 0 are filtered out, and the network cards whose OperationalStatus is not UP are filtered out, and the remaining ones are available network cards. The information of the available network cards obtained after filtering is stored in the memory, such as saved in netaddresses.
[0062] Step 204, determine whether there is an available network card. If yes, execute step 205; if not, return to step 203 and wait in a loop.
[0063] By reading the information in the memory netaddresses, if the number of network cards in netaddresses is 0, it will wait in a loop until netaddresses contains information about available network cards.
[0064] Step 205 , determine whether there are any reduced available network cards. If yes, execute step 206 ; if no, execute step 210 .
[0065] After reading the network card information once and determining the available network cards, the information of the available network cards determined this time can be compared with the information of the available network cards determined last time and saved in the memory. For example, the network card identifiers can be compared to determine whether there are fewer available network cards compared to the available network cards determined last time. For example, when the user pulls out a network card, the first thread can determine that one available network card has been reduced by comparing the available network cards determined this time with the available network cards determined last time. If there are fewer available network cards, the reduced available network cards can be stored in removecard in the memory.
[0066] Step 206, whether the reduced available network card has a heartbeat thread. If yes, execute step 207; if no, execute step 208.
[0067] Step 207: close the heartbeat thread of the reduced available network card.
[0068] For the reduced available network card, there is no need to continue to regularly detect the status of the network card through the heartbeat thread. Therefore, if there is a heartbeat thread between the reduced available network card and the server, the TCP connection and the heartbeat thread between the reduced available network card and the server can be matched through the IP address of the reduced available network card, the TCP (Transmission Control Protocol) connection between the reduced available network card and the server can be disconnected, and the heartbeat thread between the reduced available network card and the server can be closed.
[0069] Step 208, determine whether the reduced available network card is in the reconnection queue. If yes, execute step 209; if not, execute step 210.
[0070] Step 209: Delete the reduced available network cards from the reconnection queue.
[0071] For the reduced available network cards, there is no need to continue the reconnection operation. Therefore, if the reduced available network cards exist in the reconnection queue, the reduced available network cards are deleted from the reconnection queue.
[0072] By performing the above-mentioned processing of disconnecting the TCP connection, closing the heartbeat thread, and deleting it from the reconnection queue on the reduced available network card, waste of resources due to the reduced available network card can be avoided.
[0073] Step 210: Start the heartbeat thread of the available network card.
[0074] For the available network card determined in step 203, the status of the available network card may be detected periodically.
[0075] In an optional implementation, the status of the available network card can be periodically detected through a heartbeat thread. For the available network card stored in the memory, the IP address of the available network card is obtained, and a TCP connection is established with the server through a socket protocol and a service address. After the TCP connection is successfully established, a heartbeat thread between the available network card and the server is started based on the TCP connection.
[0076] Step 211, determine whether the heartbeat is normal. If yes, execute step 212; if no, execute step 213.
[0077] The heartbeat thread sends a heartbeat to the server at regular intervals. The server replies with a heartbeat after receiving it. If the client can receive a heartbeat reply from the server after sending a heartbeat, it means the heartbeat is normal; if the client does not receive a heartbeat reply from the server after sending a heartbeat, it means the heartbeat is abnormal.
[0078] For the time interval for sending heartbeats, any applicable value can be set according to actual experience. For example, a heartbeat can be sent every 3s, 5s, 7s, etc., and the embodiment of the present invention does not limit this.
[0079] Step 212: Mark the available network cards in the online state as online.
[0080] If the heartbeat of the available network card is normal, it means that the network communication is normal. At this time, mark this available network card as online.
[0081] Step 213: Add the available network card in offline state to the reconnection queue.
[0082] If the heartbeat of the available network card is abnormal, it means that the network communication is abnormal, and the available network card is marked as offline. For the available network card in the offline state, it is added to the reconnection queue as the network card to be reconnected. Specifically, the network card information corresponding to the available network card in the offline state is added to the reconnection queue.
[0083] Step 214, close the heartbeat thread of the available network card in the offline state.
[0084] For an available network card in an offline state, the TCP connection between the available network card in an offline state and the server is disconnected, and the heartbeat thread between the available network card in an offline state and the server is closed to save resources.
[0085] Step 215, start the second thread.
[0086] Step 216, read the network card information in the reconnection queue.
[0087] Step 217: reconnect the network cards in the reconnection queue.
[0088] The network card information in the reconnection queue is read through the second thread, and a reconnection operation is performed on each network card to be reconnected in the reconnection queue.
[0089] The process of performing a reconnection operation on each network card to be reconnected in the reconnection queue includes: establishing a TCP connection between the network card to be reconnected and a server; and starting a heartbeat thread between the network card to be reconnected and the server based on the TCP connection.
[0090] Step 218, determine whether the reconnection is successful. If yes, execute step 222; if no, execute step 219.
[0091] If the TCP connection is successful and the heartbeat thread is started successfully, it means that the reconnection is successful. In this case, the network card that has successfully reconnected can be deleted from the reconnection queue, and the status of the network card to be reconnected can be regularly detected through the heartbeat thread, and the execution of step 211 is returned to determine whether the heartbeat is normal.
[0092] Step 219, record the number of reconnections.
[0093] Step 220, determine whether the number of reconnections reaches a preset threshold. If yes, execute step 221; if no, return to execute step 217 to continue reconnecting.
[0094] If the TCP connection fails, or the heartbeat thread fails to start, it means that the reconnection fails. At this time, the number of reconnections is recorded, and it is determined whether the number of reconnections reaches the preset threshold. For the specific value of the preset threshold, any applicable value can be set according to the actual situation, such as setting the threshold to 5 times, 8 times, 10 times, etc., which is not limited in the embodiment of the present invention.
[0095] Step 221, stop reconnecting and display a prompt message.
[0096] For the network card that fails to reconnect, if the number of reconnections of the network card that fails to reconnect reaches a preset threshold, the reconnection operation on the network card that fails to reconnect is stopped, and a network card abnormality prompt message is displayed; if the number of reconnections of the network card that fails to reconnect does not reach the preset threshold, the reconnection operation on the network card that fails to reconnect continues.
[0097] Step 222, deleting the network card that has successfully reconnected from the reconnection queue.
[0098] There is no need to continue to reconnect the network card that has successfully reconnected, so the network card that has successfully reconnected is deleted from the reconnection queue.
[0099] In the embodiment of the present invention, in the case of multi-card aggregation, the status of the network card can be judged timely and effectively, and the insertion, removal, normal communication, communication interruption, etc. of the network card can be detected, as well as the reconnection and recovery after the communication interruption can be realized.
[0100] Embodiment 3
[0101] Reference Figure 3 , shows a structural block diagram of a network card processing device according to embodiment 3 of the present invention.
[0102] like Figure 3 As shown, the network card processing device may include the following modules:
[0103] The first determination module 301 is used to periodically read the network card information of each network card and determine the available network card according to the network card information;
[0104] The detection module 302 is used to periodically detect the status of the available network cards, and add the available network cards in the offline state as the network cards to be reconnected to the reconnection queue;
[0105] A reconnection module 303 is used to perform a reconnection operation on each network card to be reconnected in the reconnection queue;
[0106] The first deleting module 304 is used to delete the network card that has successfully reconnected from the reconnection queue.
[0107] In the embodiment of the present invention, the available network cards can be determined by regularly reading the network card information, and the status of the available network cards is regularly detected. On the one hand, unnecessary detection of unavailable network cards is avoided, and the number of detected network cards is reduced; on the other hand, the network card status can be known more timely through regular detection. By adding the available network cards in the offline state as the network cards to be reconnected to the reconnection queue, and performing the reconnection operation on each network card to be reconnected in the reconnection queue, and deleting the network card that has been successfully reconnected from the reconnection queue, it is possible to automatically reconnect and restore the available network cards in the offline state.
[0108] Embodiment 4
[0109] Reference Figure 4 , shows a structural block diagram of a network card processing device according to a fourth embodiment of the present invention.
[0110] like Figure 4 As shown, the network card processing device may include the following modules:
[0111] The first determination module 401 is used to periodically read the network card information of each network card and determine the available network card according to the network card information;
[0112] The detection module 402 is used to periodically detect the status of the available network cards, and add the available network cards in the offline state as the network cards to be reconnected to the reconnection queue;
[0113] A reconnection module 403 is used to perform a reconnection operation on each network card to be reconnected in the reconnection queue;
[0114] The first deleting module 404 is configured to delete the network card that has successfully reconnected from the reconnection queue.
[0115] Optionally, the detection module 402 includes: a first establishment unit, used to establish a TCP connection between the available network card and the server; a thread detection unit, used to start a heartbeat thread between the available network card and the server based on the TCP connection, and periodically detect the status of the available network card through the heartbeat thread.
[0116] Optionally, the device also includes: a first closing module 405, which is used to disconnect the TCP connection between the available network card in the offline state and the server after the detection module 402 adds the available network card in the offline state as the network card to be reconnected to the reconnection queue, and close the heartbeat thread between the available network card in the offline state and the server.
[0117] Optionally, the device also includes: a second determination module 406, used to determine whether there is a reduced available network card after the first determination module 401 determines the available network card based on the network card information; a second closing module 407, used to disconnect the TCP connection between the reduced available network card and the server and close the heartbeat thread between the reduced available network card and the server when there is a reduced available network card, if there is a heartbeat thread between the reduced available network card and the server; a second deletion module 408, used to delete the reduced available network card from the reconnection queue when there is a reduced available network card in the reconnection queue.
[0118] Optionally, the device further includes: a failure processing module 409, which is used to stop reconnecting the network card that failed to reconnect if the number of reconnections of the network card that failed to reconnect reaches a preset threshold, and display network card abnormality prompt information.
[0119] Optionally, the first determination module 401 is specifically used to start a first thread, and periodically read the network card information of each network card through the first thread, and determine the available network cards based on the network card information; the reconnection module 403 is specifically used to start a second thread, and perform a reconnection operation on each network card to be reconnected in the reconnection queue through the second thread.
[0120] Optionally, the first determining module 401 includes: an information reading unit, configured to call a network card information reading function in a system bottom layer function to read the network card information of each network card.
[0121] Optionally, the network card information includes the speed and working status of the network card; the first determination module 401 includes: a network card determination unit, configured to determine a network card whose speed is greater than or equal to zero and whose working status is a startup state as an available network card.
[0122] Optionally, the reconnection module 403 includes: a second establishing unit, used to establish a TCP connection between the network card to be reconnected and the server; and a thread starting unit, used to start a heartbeat thread between the network card to be reconnected and the server based on the TCP connection.
[0123] In the embodiment of the present invention, in the case of multi-card aggregation, the status of the network card can be judged timely and effectively, and the insertion, removal, normal communication, communication interruption, etc. of the network card can be detected, as well as the reconnection and recovery after the communication interruption can be realized.
[0124] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0125] In an embodiment of the present invention, an electronic device is also provided. The electronic device may include one or more processors, and one or more machine-readable media storing instructions thereon, the instructions being, for example, application programs. When the instructions are executed by the one or more processors, the processors execute the above-mentioned network card processing method.
[0126] In an embodiment of the present invention, a non-temporary computer-readable storage medium is also provided, on which a computer program is stored, and the program can be executed by a processor of an electronic device to complete the above-mentioned network card processing method. For example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0127] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0128] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0129] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0130] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0131] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0132] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0133] Finally, 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 terminal 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 terminal 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 terminal device including the elements.
[0134] The network card processing method, device, electronic device and storage medium provided by the present invention are introduced in detail above. The principle and implementation mode of the present invention are explained by using specific examples in this article. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A network card processing method, It is characterized in that The method comprises: Start a first thread, read the network card information of each network card regularly through the first thread, determine the available network card according to the network card information; regularly detect the status of the available network card, add the available network card in the offline state as the network card to be reconnected to the reconnection queue; determine whether there is a reduction in the available network card; when there is a reduction in the available network card, if the reduced available network card exists in the reconnection queue, delete the reduced available network card from the reconnection queue; wherein the network card information includes the speed and working status of the network card, and the available network card includes a network card with a speed greater than or equal to zero and a working status of the startup state; A second thread is started, and a reconnection operation is performed on each network card to be reconnected in the reconnection queue through the second thread; the network card that has successfully reconnected is deleted from the reconnection queue; for the network card that failed to reconnect, if the number of reconnections of the network card that failed to reconnect reaches a preset threshold, the reconnection operation on the network card that failed to reconnect is stopped.
2. The method according to claim 1, It is characterized in that The timed detection of the state of the available network card includes: Establishing a TCP connection between the available network card and the server; Based on the TCP connection, a heartbeat thread between the available network card and the server is started, and the state of the available network card is periodically detected through the heartbeat thread.
3. The method according to claim 2, It is characterized in that After adding the available network card in the offline state as the network card to be reconnected to the reconnection queue, the method further includes: The TCP connection between the available network card in the offline state and the server is disconnected, and the heartbeat thread between the available network card in the offline state and the server is closed.
4. The method according to claim 2, It is characterized in that After determining whether there are fewer available network cards, also include: When there is a reduced available network card, if there is a heartbeat thread between the reduced available network card and the server, the TCP connection between the reduced available network card and the server is disconnected, and the heartbeat thread between the reduced available network card and the server is closed.
5. The method according to claim 1, It is characterized in that After stopping the reconnection operation on the network card that failed to reconnect, the method further includes: Displays network card abnormality prompt information.
6. The method according to claim 1, It is characterized in that The reading of the network card information of each network card includes: The network card information reading function in the system bottom layer function is called to read the network card information of each network card.
7. The method according to claim 1, It is characterized in that The performing a reconnection operation on each network card to be reconnected in the reconnection queue includes: Establishing a TCP connection between the network card to be reconnected and the server; Based on the TCP connection, a heartbeat thread is started between the network card to be reconnected and the server.
8. A network card processing device, It is characterized in that The device comprises: A first determination module is used to start a first thread, periodically read network card information of each network card through the first thread, and determine an available network card according to the network card information; the network card information includes the speed and working state of the network card, and the available network card includes a network card whose speed is greater than or equal to zero and whose working state is a startup state; A detection module, configured to periodically detect the status of the available network cards through the first thread, and add the available network cards in an offline state as network cards to be reconnected to a reconnection queue; A second determining module, configured to determine whether there are reduced available network cards through the first thread; A second deleting module, configured to, when there is a reduced available network card, delete the reduced available network card from the reconnection queue if the reduced available network card exists in the reconnection queue through the first thread; A reconnection module, used for starting a second thread, and performing a reconnection operation on each network card to be reconnected in the reconnection queue through the second thread; A first deleting module, configured to delete the successfully reconnected network card from the reconnection queue through the second thread; The failure processing module is used to stop performing the reconnection operation on the network card that failed to reconnect through the second thread if the number of reconnections of the network card that failed to reconnect reaches a preset threshold.
9. An electronic device, It is characterized in that include: one or more processors; and one or more machine-readable media having instructions stored thereon; When the instructions are executed by the one or more processors, the processors are caused to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, It is characterized in that A computer program is stored thereon, and when the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
