CN111683094B - Method and device for client to select port in TCP communication, computer equipment and storage medium - Google Patents

Method and device for client to select port in TCP communication, computer equipment and storage medium Download PDF

Info

Publication number
CN111683094B
CN111683094B CN202010517920.6A CN202010517920A CN111683094B CN 111683094 B CN111683094 B CN 111683094B CN 202010517920 A CN202010517920 A CN 202010517920A CN 111683094 B CN111683094 B CN 111683094B
Authority
CN
China
Prior art keywords
port
queue
client
head
server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010517920.6A
Other languages
Chinese (zh)
Other versions
CN111683094A (en
Inventor
苗海柱
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202010517920.6A priority Critical patent/CN111683094B/en
Publication of CN111683094A publication Critical patent/CN111683094A/en
Application granted granted Critical
Publication of CN111683094B publication Critical patent/CN111683094B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/163In-band adaptation of TCP data exchange; In-band control procedures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer And Data Communications (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a method and a device for selecting a port by a client during TCP communication, wherein the method comprises the following steps: calling a port at the head of a port queue from a pre-established client port queue; connecting the port of the server side by the port which is called and positioned at the head of the port queue; placing the called port at the head of the port queue at the tail of the client port queue, and regenerating a client port queue; if the connection of the server port is unsuccessful, connecting the server port with a port which is positioned at the head of the port queue in the regenerated client port queue; and repeating the steps until the server port is successfully connected. The invention can make the client terminal port connect with the server terminal in a queue order mode, solves the problem of communication connection failure caused by repeated use of a certain port of the client terminal, avoids the problem of cost increase caused by increasing the range of the port, does not increase the whole communication duration, does not need to additionally increase an application layer, and is suitable for various scenes.

Description

Method and device for client to select port in TCP communication, computer equipment and storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for selecting a port by a client during TCP communication.
Background
When performing TCP (Transmission Control Protocol) communication programming, because the operating system processes different underlying mechanisms of the TCP Protocol, the problem of connection establishment failure due to quintuple repetition does not basically occur in the communication from the client side with the operating system AIX to the server side with the operating system AIX, the communication from the client side with the operating system Linux to the server side with the operating system Linux, and the communication from the client side with the operating system AIX to the server side with the operating system Linux. When the client with the Linux operating system communicates with the AIX operating system server, the problem of connection establishment failure due to Socket communication quintuple repetition occurs due to the problem of the operating system bottom layer mechanism.
In TCP communication programming, a client generally initiates a socket command for establishing a connection with a server, and an operating system of the client selects a port to connect with the server. In the prior art, if the os of the client is an AIX os, the ports are selected in the available range according to the order of the ports. When the operating system of the client is a Linux operating system, a random mode is adopted when selecting the port, and the port is selected within the range of the available port, which results in a higher probability that the same port is repeatedly used in a short TIME in a high concurrency scene, and at this TIME, if the port state of the server is in a TIME _ WAIT state (the shortest release TIME of the state is 30 seconds), connection establishment failure is caused by the repetition of Socket communication quintuple.
In the prior art, to solve the problem of connection establishment failure caused by quintuple repetition in a high-concurrency scenario in communication from a client whose operating system is Linux to a server whose operating system is AIX, three methods of expanding an available port range (through system parameter configuration), increasing connection establishment timeout time, and increasing a connection retry mechanism are generally adopted:
1. and (3) increasing the port range: the increase of the port range can reduce the probability of randomly reaching the same port when the operating system selects the port, but the method can only reduce the quintuple repetition probability and cannot solve the problem that the same port is repeatedly used in a short time;
2. increasing the connection establishment timeout: during TCP communication, if the connection is not established for the first time, the operating system may reinitiate the connection after 1 second interval. The method can prolong the whole communication time, and is not suitable for processing time-consuming and sensitive scenes by the system because the time for waiting for reconnection is 1 second;
3. adding a connection retry mechanism: the application layer realizes connection retry, and the method needs to consider various abnormal scenes and influences end-to-end monitoring between systems, so the implementation cost is high.
Disclosure of Invention
The embodiment of the invention provides a method for selecting a port by a client during TCP communication, which is applied to a Linux client to initiate TCP communication to an AIX server and is used for solving the problem of failure of connection of the port of the client during TCP communication, and comprises the following steps:
calling a port positioned at the head of a port queue from a pre-established client port queue;
connecting the port of the server side by the port which is called and positioned at the head of the port queue;
placing the called port at the head of the port queue at the tail of the client port queue, and regenerating a client port queue;
if the connection of the server port is unsuccessful, connecting the server port with a port which is positioned at the head of the port queue in the regenerated client port queue; and repeating the steps of regenerating a client port queue and connecting the server port by using the port positioned at the head of the port queue in the regenerated client port queue until the server port is successfully connected or the number of times of connecting the server port exceeds the preset number.
The embodiment of the invention also provides a device for selecting the port by the client during TCP communication, which is applied to the Linux client to initiate the TCP communication to the AIX server so as to solve the problem of the connection failure of the port of the client during the TCP communication, and comprises the following components:
the queue head port calling module is used for calling a port at the head of a port queue from a pre-established client port queue;
the port connection module is used for connecting a server port with a called port positioned at the head of the port queue;
the port queue updating module is used for placing the called port positioned at the head of the port queue at the tail of the client port queue and regenerating a client port queue;
the repeated connection module is used for connecting the server port by using the port which is positioned at the head of the port queue in the regenerated client port queue if the connection of the server port is unsuccessful; and repeating the steps of regenerating a client port queue and connecting the server port by using the port positioned at the head of the port queue in the regenerated client port queue until the server port is successfully connected or the number of times of connecting the server port exceeds the preset number.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor executes the computer program to realize the method for selecting the port by the client during TCP communication.
The embodiment of the invention also provides a computer readable storage medium, which stores a computer program for executing the method for selecting the port by the client during the TCP communication.
In the embodiment of the invention, when a Linux client side carries out TCP communication to an AIX server side, a port positioned at the head of a port queue is called from a pre-established client side port queue; connecting the port of the server side by the port which is called and positioned at the head of the port queue; placing the called port at the head of the port queue at the tail of the client port queue, and regenerating a client port queue; if the connection of the server port is unsuccessful, connecting the server port with a port which is positioned at the head of the port queue in the regenerated client port queue; the steps are repeatedly executed until the port of the service end is successfully connected or the number of times of connecting the port of the service end exceeds the preset number of times, so that the port at the head of the port queue is directly called to connect the port of the service end, the port of the client end can be connected with the service end in a queue sequence mode, and the problem that communication connection fails due to repeated use of a certain port of the client end is solved. Compared with the prior art, the problem of cost increase caused by increasing the range of the port is avoided, meanwhile, the overall duration of communication is not increased, an additional application layer is not needed, the use cost is reduced, the method is suitable for various scenes, and the application range is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic flowchart illustrating a method for selecting a port by a client during TCP communication according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a method for selecting a port by a client during TCP communication according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a device for selecting a port by a client during TCP communication according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a device for selecting a port by a client during TCP communication according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a device for selecting a port by a client during TCP communication according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Embodiments of the present invention relate to the following terms, which are explained as follows:
socket communication quintuple comprising: source IP address, source port, transport layer protocol (protocol type), destination IP address, destination port. Only if 5 elements are identical will the system identify the same socket, i.e. the same connection.
Thread safety queue: for the use of one queue, the use of the queue is thread-safe without special control, namely, the multithreading operation and the same queue do not generate abnormity. For example, Vector (a thread-safe collection class in java language) is a thread-safe queue.
In the embodiment of the present invention, a method for a client to select a port during TCP communication is provided, where the method is applied to a Linux client to perform TCP communication to an AIX server, and as shown in fig. 1, the method includes:
step 101: calling a port at the head of a port queue from a pre-established client port queue;
step 102: connecting the port of the server side by the port which is called and positioned at the head of the port queue;
step 103: placing the called port at the head of the port queue at the tail of the client port queue, and regenerating a client port queue;
step 104: if the connection of the server port is unsuccessful, connecting the server port with a port which is positioned at the head of the port queue in the regenerated client port queue; and repeating the steps until the service port is successfully connected or the number of times of connecting the service port exceeds the preset number.
In the embodiment of the invention, when a Linux client side carries out TCP communication to an AIX server side, a port positioned at the head of a port queue is called from a pre-established client side port queue; connecting the port of the server side by the port which is called and positioned at the head of the port queue; placing the called port at the head of the port queue at the tail of the client port queue, and regenerating a client port queue; if the connection of the server port is unsuccessful, connecting the server port with a port which is positioned at the head of the port queue in the regenerated client port queue; the steps are repeatedly executed until the port of the service end is successfully connected or the number of times of connecting the port of the service end exceeds the preset number of times, so that the port at the head of the port queue is directly called to connect the port of the service end, the port of the client end can be connected with the service end in a queue sequence mode, and the problem that communication connection fails due to repeated use of a certain port of the client end is solved. Compared with the prior art, the problem of cost increase caused by increasing the range of the port is avoided, meanwhile, the overall duration of communication is not increased, an additional application layer is not needed, the use cost is reduced, the method is suitable for various scenes, and the application range is improved.
In specific implementation, a port located at the head of a port queue is called from a pre-established client port queue, and there are various methods for establishing the client port queue, and one of the following embodiments is provided.
In one embodiment, establishing a client port queue may include: acquiring all available client ports, and determining port elements corresponding to each available client port; and generating a client port queue with thread safety according to all the port elements.
In an embodiment, the sequentially selected port ranges are configurable, a thread-safe client port queue, i.e., an initialization port, is generated as a data source for acquiring ports during a transaction, and the configured port ranges or sets are used to generate a thread-safe queue for use in selecting ports. The initialization is executed once only when the service is started, the configured port range is generated into a thread safety queue, and queue elements are available ports, so that the application process of the embodiment of the invention is simplified, and the overall connection time is saved.
In specific implementation, after a client port queue is established, a port at the head of the port queue is called. And calling the port at the head of the port queue may include: acquiring a port element positioned at the head of a port queue; calling a port of a port element corresponding to the head of the port queue;
placing the called port located at the head of the port queue at the end of the client port queue, and regenerating a client port queue, which may include: and placing the first port element of the port queue at the tail of the client port queue, and regenerating a client port queue.
In one embodiment, when the client communication thread selects a port, a port element is selected from the head of the queue as a port for connecting the server, and the port element is placed at the tail of the queue, so that the client port can be used as a circular queue, and the ports can be used in a set port range in a circulating sequence.
In specific implementation, after a port located at the head of a port queue is called, there are various methods for connecting a service port with the called port located at the head of the port queue, and one of the following embodiments is provided.
In one embodiment, connecting the service port with the called port located at the head of the port queue may include: and actively connecting the port of the server side with the port which is called and positioned at the head of the port queue through a binding method.
When the client-side communication establishes Socket sockets by Socket communication quintuple, the called port at the head of the port queue is actively bound by a binding method instead of a default selection mode determined by an operating system. According to the embodiment of the invention, the port is selected by the Linux operating system, application intervention judgment processing is not needed, and active binding of the port also needs to judge whether the current port is available, so that the problem of binding failure caused by the fact that other system processes use the port is avoided.
In specific implementation, after the server port is connected, if the server port is not connected successfully, the server port is connected with a port positioned at the head of a port queue in the regenerated client port queue; and repeating the steps until the service port is successfully connected or the number of times of connecting the service port exceeds the preset number.
In one embodiment, after the connection of the server port, it is also necessary to determine whether the connection of the server port is successful, and if so, continue the service processing; if the connection of the server port is unsuccessful, connecting the server port with a port which is positioned at the head of the port queue in the regenerated client port queue; repeatedly executing the steps until the server port is successfully connected or the number of times of connecting the server port exceeds a preset number of times; if the number of times of connecting the server port exceeds the preset number, reporting an error to the client operating system, recording error reporting data, and ending the step of connecting the server port, wherein the preset number can be configured by the application parameters.
In specific implementation, the method for selecting a port by a client during TCP communication according to the embodiment of the present invention, as shown in fig. 2, may further include:
step 105: setting a time threshold for port closing; after the called port located at the head of the port queue is connected with the service port, the connected port is closed after the time threshold of port closing.
In the embodiment, after the time threshold of port closing, the connected port is closed, so that the situation that the client port is connected for too long time can be avoided, and the situation that the client port is occupied for a long time is avoided.
In the embodiment of the invention, when a Linux client side carries out TCP communication to an AIX server side, a port positioned at the head of a port queue is called from a pre-established client side port queue; connecting the port of the server side by the port which is called and positioned at the head of the port queue; placing the called port at the head of the port queue at the tail of the client port queue, and regenerating a client port queue; if the connection of the server port is unsuccessful, connecting the server port with a port which is positioned at the head of the port queue in the regenerated client port queue; the steps are repeatedly executed until the port of the server is successfully connected or the number of times of connecting the port of the server exceeds the preset number of times, so that the port at the head of the port queue is directly called to connect the port of the server, the port of the client can be connected with the server in a queue sequence mode, and the problem of communication connection failure caused by repeated use of a certain port of the client is solved. Compared with the prior art, the problem of cost increase caused by increasing the range of the port is avoided, meanwhile, the overall duration of communication is not increased, an additional application layer is not needed, the use cost is reduced, the method is suitable for various scenes, and the application range is improved.
In the embodiment, when the client side with the Linux operating system selects the port, if the client side is connected in a random mode, the algorithm of the random mode is determined by the kernel algorithm, so that the sequential selection algorithm cannot be realized by modifying the system parameter configuration. If the available port range is sufficient at the peak pressure of the system, the problem of connection establishment failure due to Socket communication quintuple repetition can be completely solved, and the probability is not only reduced.
In the embodiment, a TCP communication mechanism is simulated, and the selection of a sequential port algorithm is realized during port selection, so that the problem of port short-time repeated use can be solved from the source. Because only the port selection algorithm is changed, the underlying communication mechanism is not changed, and therefore the time consumption of the transaction is not influenced. The embodiment of the invention aims at the processing of a TCP communication layer, has no invasion influence on application, so the application development cost is lower, and the problem of random selection of a Linux system can be avoided by actively selecting the port range and realizing sequential use, thereby achieving the most effective use of the port. If temporary ports can be selected in sequence, the client can only use all ports in the range once, so that the problem of connection establishment failure caused by Socket communication quintuple repetition due to the fact that the same port is selected in a short time is solved.
Based on the same inventive concept, the embodiment of the present invention further provides a device for selecting a port by a client during TCP communication, as described in the following embodiments. Because the principle of solving the problem of the device for selecting the port by the client during the TCP communication is similar to the method for selecting the port by the client during the TCP communication, the implementation of the device for selecting the port by the client during the TCP communication can be referred to the implementation of the method for selecting the port by the client during the TCP communication, and repeated parts are not described again. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
Fig. 3 is a block diagram of a structure of a device for selecting a port by a client during TCP communication according to an embodiment of the present invention, as shown in fig. 3, including:
a queue head port calling module 01, configured to call a port located at the head of a port queue from a pre-established client port queue;
the port connection module 02 is used for connecting a server port with a called port located at the head of a port queue;
the port queue updating module 03 is configured to place the called port located at the head of the port queue at the end of the client port queue, and regenerate a client port queue;
the repeated connection module 04 is used for connecting the server port with the port located at the head of the port queue in the regenerated client port queue if the connection with the server port is unsuccessful; and repeating the steps until the service port is successfully connected or the number of times of connecting the service port exceeds the preset number.
In an embodiment, the apparatus for selecting a port by a client during TCP communication according to an embodiment of the present invention, as shown in fig. 4, may further include: the port queue establishing module 001 is configured to establish a client port queue, and includes: acquiring all available client ports, and determining port elements corresponding to each available client port; and generating a client port queue with thread safety according to all the port elements.
In an embodiment, the queue head port calling module is specifically configured to: acquiring a port element positioned at the head of a port queue; calling the port of the port element corresponding to the head of the port queue; the port queue updating module is specifically configured to: and placing the first port element of the port queue at the tail of the client port queue, and regenerating a client port queue.
In an embodiment, the port connection module is specifically configured to: and actively connecting the port of the server side with the port which is called and positioned at the head of the port queue through a binding method.
In an embodiment, the apparatus for selecting a port by a client during TCP communication according to an embodiment of the present invention, as shown in fig. 5, may further include: a port timeout control module 05 configured to: setting a time threshold for closing the port; after the called port located at the head of the port queue is connected with the port of the service end, the connected port is closed after the time threshold value of port closing.
The embodiment of the invention also provides computer equipment which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the processor executes the computer program to realize the method for selecting the port by the client during the TCP communication.
The embodiment of the invention also provides a computer readable storage medium, which stores a computer program for executing the method for selecting the port by the client during the TCP communication.
In the embodiment of the invention, when a Linux client side carries out TCP communication to an AIX server side, a port positioned at the head of a port queue is called from a pre-established client side port queue; connecting the port of the server side by the port which is called and positioned at the head of the port queue; placing the called port at the head of the port queue at the tail of the client port queue, and regenerating a client port queue; if the connection of the server port is unsuccessful, connecting the server port with a port which is positioned at the head of the port queue in the regenerated client port queue; the steps are repeatedly executed until the port of the server is successfully connected or the number of times of connecting the port of the server exceeds the preset number of times, so that the port at the head of the port queue is directly called to connect the port of the server, the port of the client can be connected with the server in a queue sequence mode, and the problem of communication connection failure caused by repeated use of a certain port of the client is solved. Compared with the prior art, the problem of cost increase caused by increasing the range of the port is avoided, meanwhile, the overall duration of communication is not increased, an additional application layer is not needed, the use cost is reduced, the method is suitable for various scenes, and the application range is improved.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes may be made to the embodiment of the present invention by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for client terminal to select port in TCP communication is characterized in that the method is applied to Linux client terminal to initiate TCP communication to AIX server terminal, and the method comprises the following steps:
calling a port at the head of a port queue from a pre-established client port queue;
connecting the port of the server side by the port which is called and positioned at the head of the port queue;
placing the called port at the head of the port queue at the tail of the client port queue, and regenerating a client port queue;
if the connection of the server port is unsuccessful, connecting the server port with a port which is positioned at the head of the port queue in the regenerated client port queue; and repeating the steps of regenerating a client port queue and connecting the server port by using the port positioned at the head of the port queue in the regenerated client port queue until the server port is successfully connected or the number of times of connecting the server port exceeds the preset number.
2. The method of claim 1, further comprising: establishing a client port queue, comprising:
acquiring all available client ports, and determining port elements corresponding to each available client port;
and generating a client port queue with thread safety according to all the port elements.
3. The method of claim 2, wherein invoking the port at the head of the port queue comprises:
acquiring a port element positioned at the head of a port queue;
calling a port of a port element corresponding to the head of the port queue;
the step of placing the called port located at the head of the port queue at the tail of the client port queue to regenerate a client port queue includes:
and placing the first port element of the port queue at the tail of the client port queue to regenerate a client port queue.
4. The method of claim 1, wherein connecting the service port with the called port at the head of the port queue comprises:
and actively connecting the port of the server side with the port which is called and is positioned at the head of the port queue through a binding method.
5. The method of claim 1, further comprising: setting a time threshold for port closing;
after the called port located at the head of the port queue is connected with the service port, the connected port is closed after the time threshold of port closing.
6. An apparatus for selecting a port by a client during TCP communication, wherein the apparatus is applied to a Linux client to initiate TCP communication to an AIX server, and the apparatus comprises:
the queue head port calling module is used for calling a port at the head of a port queue from a pre-established client port queue;
the port connection module is used for connecting the port of the server side by the called port positioned at the head of the port queue;
the port queue updating module is used for placing the called port positioned at the head of the port queue at the tail of the client port queue and regenerating a client port queue;
the repeated connection module is used for connecting the server port by using the port which is positioned at the head of the port queue in the regenerated client port queue if the connection of the server port is unsuccessful; and repeating the steps of regenerating a client port queue and connecting the server port by using the port positioned at the head of the port queue in the regenerated client port queue until the server port is successfully connected or the number of times of connecting the server port exceeds the preset number.
7. The apparatus of claim 6, further comprising: the port queue establishing module is used for establishing a client port queue and comprises the following steps:
acquiring all available client ports, and determining port elements corresponding to each available client port;
and generating a client port queue with thread safety according to all the port elements.
8. The apparatus of claim 6, wherein the port connection module is specifically configured to:
and actively connecting the port of the server side with the port which is called and is positioned at the head of the port queue through a binding method.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 5 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the method of any one of claims 1 to 5.
CN202010517920.6A 2020-06-09 2020-06-09 Method and device for client to select port in TCP communication, computer equipment and storage medium Active CN111683094B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010517920.6A CN111683094B (en) 2020-06-09 2020-06-09 Method and device for client to select port in TCP communication, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010517920.6A CN111683094B (en) 2020-06-09 2020-06-09 Method and device for client to select port in TCP communication, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111683094A CN111683094A (en) 2020-09-18
CN111683094B true CN111683094B (en) 2022-06-17

Family

ID=72435635

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010517920.6A Active CN111683094B (en) 2020-06-09 2020-06-09 Method and device for client to select port in TCP communication, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111683094B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106790480A (en) * 2016-12-12 2017-05-31 中国航空工业集团公司西安航空计算技术研究所 A kind of document transmission method under the conditions of the link for link aggregation
CN108551460A (en) * 2018-07-20 2018-09-18 南京工程学院 A kind of SOCKET communication establishing methods under complex network environment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020184316A1 (en) * 2001-04-17 2002-12-05 Thomas Huw K. System and method for MAPI client server communication
US20060123120A1 (en) * 2004-04-08 2006-06-08 Thomas Merkh Methods for establishing and validating sessions

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106790480A (en) * 2016-12-12 2017-05-31 中国航空工业集团公司西安航空计算技术研究所 A kind of document transmission method under the conditions of the link for link aggregation
CN108551460A (en) * 2018-07-20 2018-09-18 南京工程学院 A kind of SOCKET communication establishing methods under complex network environment

Also Published As

Publication number Publication date
CN111683094A (en) 2020-09-18

Similar Documents

Publication Publication Date Title
CN108124003B (en) Network management equipment connection processing method, device and system
CN106681924B (en) A kind of method for testing software and system
CN109698771B (en) Game server pressure testing method and device
EP3550436A1 (en) Method and apparatus for detecting and recovering fault of virtual machine
WO2018019242A1 (en) Self-recovery method and self-recovery system for web server
WO2018006702A1 (en) Abnormality processing method, apparatus and system in automation test
CN109978290A (en) A kind of operation flow backspacing processing method of extensive makeup, flow engine and operation system
CN112953983A (en) SFTP transmission method and device
US9882779B2 (en) Software version maintenance in a software defined network
CN111885112A (en) Node service exception handling method, device, equipment and storage medium
CN111683094B (en) Method and device for client to select port in TCP communication, computer equipment and storage medium
CN108259358A (en) route issuing method and device
CN111031123B (en) Spark task submission method, system, client and server
CN109450724A (en) A kind of test method and relevant apparatus of NFS internal memory optimization function
CN116361114A (en) AI board monitoring keep-alive method, device, equipment and medium
CN111190761B (en) Log output method and device, storage medium and electronic equipment
CN108616381B (en) Event correlation alarm method and device
CN115168236A (en) Automatic testing method, electronic device and storage medium
CN111614649B (en) Method and device for closing TCP short connection
CN111064636B (en) Control method, device and system for connection of front-end processor and computer equipment
CN111124705B (en) Service request processing method and device
CN113900952A (en) Test case execution method and device, terminal equipment and readable storage medium
CN110874238B (en) Online service updating method and device
CN107870777A (en) A kind of hot patch implementation method and device, terminal
CN116974815B (en) Data center disaster recovery switching method and device based on chaotic engineering fault drilling

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant