Network connection method, system, device and medium

By creating readable and writeable control scripts in the kernel, establishing socket channels and sending request messages, the problem of slow connection speed to external server ports in the existing technology is solved, and fast connection and efficient response are achieved.

CN115484302BActive Publication Date: 2025-05-27PINGAN YIQIANBAO E COMMERCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211120810.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-15
Publication Date
2025-05-27
Estimated Expiration
2042-09-15

AI Technical Summary

Technical Problem

The prior art relies too much on port code or application environment when calling external server ports, resulting in the inability to achieve quick connection to external server ports.

Method used

By creating a readable and writeable control script in the kernel, a socket channel is established based on the address information of the network to be called and the preset communication protocol, and the request information is encapsulated into a request message. The request message is sent to the network to be called through the control script, and the response information is received and sent to the connection requester.

Benefits of technology

It realizes quick connection to external server ports, avoids dependence on port code or application environment, breaks through the bottleneck of inaccessible network in the existing technology, and improves response efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115484302B_ABST
    Figure CN115484302B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of cloud transmission technology, and provides a network connection method, system, device and medium. The connection method includes: obtaining a connection request, where the connection request includes the data transmission protocol and request information of the network to be called, as well as the address information of the network to be called; creating a readable and writable control script in the kernel, and establishing a socket channel with the network to be called through the control script according to the address information and a preset communication protocol; encapsulating the request information into a request message according to the data transmission protocol, writing the request message into the control script, and sending the request message to the network to be called through the control script; receiving the response information returned according to the request message and writing it into the control script; and sending the response information to the connection requester through the control script. The present invention solves the problem of quickly connecting to an external network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cloud transmission, and particularly to a network connection method, system, device and medium. Background Art

[0002] With the development of computer technology, more and more services can be realized by computers. That is, in the process of service realization, port call requests can be sent from a terminal to corresponding ports of a server, so as to call the ports and realize relevant services.

[0003] In the prior art, in order to call the ports of a server, the curl, telnet commands or a fully emulated manner on a local server are usually used to simulate port calls. For the case of using commands to call, the syntax of the URL is used to transmit data or files, so as to read the data in the ports. For simulating port calls, a simulation environment that is exactly the same as the application environment of an external server is created on a local server, so as to realize the simulated call of the external server ports on the local server.

[0004] The inventor realizes that the above curl and telnet command methods are both based on the terminal having written corresponding port call codes. And writing call codes takes a long time for engineering personnel, and once the code is written incorrectly, the port cannot be called. For the method of using a fully emulated manner to call ports, in engineering practice, it is almost impossible to fully emulate and verify the ports of a server. Therefore, the above methods cannot achieve a fast connection to the external server ports due to relying on port codes or application environments. Summary of the Invention

[0005] The purpose of the present invention is to provide a network connection method, system, device and medium, so as to solve the problem that the existing network connection methods rely too much on port codes or application environments, and thus cannot achieve a fast connection to external network ports.

[0006] In a first aspect, a network connection method is provided, including:

[0007] Obtaining a connection request, where the connection request includes a data transmission protocol and request information for data to be called from a network, and address information of the network to be called;

[0008] Creating a readable and writable control script in the kernel, and establishing a socket channel with the network to be called through the control script according to the address information and a preset communication protocol;

[0009] According to the data transmission protocol, encapsulate the request information into a request message, write the request message into the control script, and send the request message to the network to be called through the control script;

[0010] Receive the response information returned according to the request message and write it into the control script;

[0011] Send the response information to the connection requester through the control script.

[0012] In a second aspect, a connection system for a network is provided. The system includes:

[0013] An information acquisition module, configured to acquire a connection request, where the connection request includes a data transmission protocol and request information for the network to be called, and address information of the network to be called;

[0014] A socket communication module, configured to create a readable and writable control script in the kernel, and establish a socket channel with the network to be called through the control script according to the address information and a preset communication protocol;

[0015] An information sending module, configured to encapsulate the request information into a request message according to the data transmission protocol, write the request message into the control script, and send the request message to the network to be called through the control script;

[0016] An information receiving module, configured to receive the response information returned according to the request message and write it into the control script

[0017] A communication module, configured to send the response information to the connection requester through the control script.

[0018] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned network connection method are implemented.

[0019] In a fourth aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned network connection method are implemented.

[0020] Connection method, system, device and medium of the network of the present invention. By obtaining a connection request sent by a connection requester, the connection request includes a data transmission protocol and request information for a network to be called, as well as address information of the network to be called. And a writable control script is created in the kernel. According to the address information and a preset communication protocol, a socket channel with the network to be called is established through the control script. Then, according to the data transmission protocol in the connection request, the request information is encapsulated into a request message, and the request message is written into the control script, and the request message is sent to the network to be called through the control script. When receiving response information returned according to the request message, the response information is written into the control script. Finally, the response information is sent to the connection requester through the control script to establish a connection with a network port. In the present invention, aiming at the phenomenon that the existing method of connecting to a network relies too much on port codes or application environments, and thus cannot achieve fast invocation of external server ports. To solve the above problems, through the created control script, the underlying code logic is called. According to the preset communication protocol, a communication channel with the network to be called is first established. Then, according to the data transmission protocol between the connection requester and the network to be called, the request information sent by the connection requester is sent to the network to be called along the established communication channel through the control script. When receiving the data returned by the network port, these data are sent to the connection requester, thus realizing the connection between the connection requester and the port. Thus, it avoids the problem that calling a network port relies too much on port codes or application environments and thus cannot achieve fast invocation of external server ports. It breaks through the bottleneck in the prior art that a network cannot be accessed without writing a port program. By using the most basic and core exec command, network requests are made by creating a way to read and write files. It realizes fast connection to a network port. By the created control script, the verification when telnet or curl is disabled is solved. Without too much additional business logic wrapping, the response is made more efficient. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts:

[0022] Figure 1 It shows a schematic diagram of an application environment of a connection method of an interface in a network in an embodiment of the present invention;

[0023] Figure 2 It shows a schematic flowchart of a connection method of an interface in a network in an embodiment of the present invention;

[0024] Figure 3 It shows a schematic flowchart of step S200 in an embodiment of the present invention;

[0025] Figure 4 It shows a schematic flowchart of step S300 in an embodiment of the present invention;

[0026] Figure 5 It shows a schematic flowchart of step S400 in an embodiment of the present invention;

[0027] Figure 6 It shows a schematic flowchart of step S420 in an embodiment of the present invention;

[0028] Figure 7 It shows a structural block diagram of a connection system of interfaces in a network in an embodiment of the present invention;

[0029] Figure 8 It is a schematic structural diagram of a computer device in an embodiment of the present invention;

[0030] Figure 9 It is another schematic structural diagram of a computer device in an embodiment of the present invention. Detailed implementation manners

[0031] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, rather than all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0032] The connection method of interfaces in the network provided by the embodiments of the present invention can be applied in, for example Figure 1In the application environment, the client communicates with the server through the network. Among them, the client communicates with the server through the network. The server can send corresponding response information through the connection request of the client. By obtaining the connection request sent by the connection requester, the connection request includes the data transmission protocol and request information of the network to be called, and the address information of the network to be called. And create a readable and writable control script in the kernel. According to the address information and the preset communication protocol, establish a socket channel with the network to be called through the control script. Then, according to the data transmission protocol in the connection request, encapsulate the request information into a request message, and write the request message into the control script. Send the request message to the network to be called through the control script. When receiving the response information returned according to the request message, write the response information into the control script. Finally, send the response information to the connection requester through the control script to establish a connection with the network port. In the present invention, aiming at the phenomenon that the existing method of connecting to the network relies too much on port codes or application environments, and thus cannot achieve the rapid call of external server ports. For the above problems, through the created control script, call the underlying code logic, and according to the preset communication protocol, first establish a communication channel with the network to be called. Then, according to the data transmission protocol between the connection requester and the network to be called, send the request information sent by the connection requester along the established communication channel to the network to be called through the control script. When receiving the data returned by the network port, send these data to the connection requester, thus realizing the connection between the connection requester and the port. Thus, it avoids the problem that the call of the network port relies too much on port codes or application environments and thus cannot achieve the rapid call of external server ports. It breaks through the bottleneck in the prior art that the network cannot be accessed without writing a port program, and adopts the most basic and core exec command to make a network request by creating a way to read and write files. It realizes the rapid connection to the network port, solves the verification when telnet or curl is disabled through the created control script, and there is no excessive additional business logic packaging, making the response more efficient. Among them, the client can be but not limited to various personal computers, laptop computers, smart phones, tablet computers, and portable wearable devices. The server can be implemented by an independent server or a server cluster composed of multiple servers. The present invention will be described in detail below through specific embodiments.

[0033] Please refer to Figure 2 as shown in Figure 2 FIG. X is a schematic flow chart of a method for connecting a network provided by an embodiment of the present invention, including the following steps:

[0034] S100. Obtain a connection request, where the connection request includes the data transfer protocol and request information for the network to be invoked, as well as the address information of the network to be invoked.

[0035] When the local client needs to obtain data from a certain port of the network to be invoked on the server, a connection request can be sent. Specifically, based on the underlying logic of the computer, a shell script can be written, and the relevant information for triggering the script to send the connection request to the control script is pre-recorded in the shell script. When a certain port of the network to be invoked needs to be connected, the user can write the URL of the network to be invoked, the request information sent to the network to be invoked, and the data transfer protocol used for the connection to the corresponding positions in the shall script. By triggering the shall script to run, the connection between the network to be invoked and the connection requester can be achieved through the created control script. Among them, the URL can include the address information of the network to be invoked, and the address information includes the domain name and port. The domain name can be an IP address or a website address, and no limitation is made here. Considering that it is not easy for users to remember IP addresses, in most cases, a website address is used as the domain name. The port is a specific port opened by the network to be invoked, and the local user can obtain the required data through this port. Exemplarily, for the Baidu homepage, its domain name is www.baidu.com and the port is 80. The request information is what content needs to be sent to the network to process the corresponding business logic after the URL locates the specific network to be connected. The network transmits the corresponding response information to the requester through the port according to the corresponding request parameters, thus realizing the connection between the requester and the network.

[0036] S200. Create a readable and writable control script in the kernel, and establish a socket channel with the network to be invoked through the control script according to the address information and the preset communication protocol.

[0037] In an embodiment of the present invention, in step S200, the creating a readable and writable control script in the kernel, and establishing a socket channel with the network to be invoked through the control script according to the address information and the preset communication protocol includes:

[0038] S210. In response to a trigger request, use the exec function to create a control script at a preset position in the kernel, where the control script supports read and write operations. Among them, the trigger request is automatically triggered after obtaining the address information of the network to be invoked, and the address information includes the domain name and port;

[0039] S220. According to the domain name of the network to be invoked, send a connection request to the port of the network to be invoked through the control script according to the preset communication protocol; where the communication protocol is the TCP / IP protocol;

[0040] S230. Receive the connection confirmation response sent from the said port. The control script sends a confirmation message to the said port again to establish a socket channel with the network to be invoked.

[0041] After the connection requester writes the relevant information of the network to be invoked into the shall script, the exec operation can be executed by triggering the shall script. The exec function family provides a method to start another program execution in a process. It can find the executable file according to the specified file name or directory name and use it to replace the data segment, code segment, and stack segment of the original calling process. After execution, all the contents of the original calling process except the process ID are replaced by the new process. Additionally, the executable file here can be either a binary file or any executable script file under Linux. Specifically, after writing the URL information of the network to be invoked into the script and running the script to send a trigger request, the exec operation can be automatically triggered. A readable and writable control script is created at a preset position in the kernel through the exec function. This control script can control the establishment of the connection between the requester and the network to be invoked and the transmission of information. The control script can perform a three-way handshake with the network to be invoked through the TCP / IP protocol according to the URL information in the script to establish a communication channel with the invoked network. Since the TCP / IP protocol is a connection-oriented, reliable, byte-stream-based transport layer communication protocol designed to adapt to the hierarchical protocol architecture supporting multiple network applications. Reliable communication services are provided between pairs of processes in the host computers connected to different but interconnected computer communication networks relying on the TCP / IP protocol. The TCP / IP protocol assumes that it can obtain a simple, possibly unreliable datagram service from a lower-level protocol. In principle, the TCP / IP protocol should be able to operate on various communication systems ranging from hard-wired connections to packet-switching or circuit-switching networks. Therefore, through the three-way handshake of the TCP / IP protocol, an effective communication channel between both parties can be established to prevent the generation of false alarms. First, perform the first handshake: According to the domain name of the network to be invoked, the local control script sends a synchronization message, called a SYN message (i.e., a connection request), to the port of the network to be invoked. Then, perform the second handshake: After receiving the synchronization message, the network to be invoked sends a synchronization confirmation message (i.e., a connection confirmation response) to the local control script, indicating that it has received the connection request from the local control script. Finally, perform the third handshake: After receiving the synchronization confirmation message, the local control script sends a confirmation message to the invoked network, that is, sends a confirmation message. At this time, the port of the invoked network and the connection requester consider that the socket channel has been established, and thus start data transmission. Through this three-way handshake process, it can effectively prevent the suddenly retransmission of expired request messages to the invoked network, resulting in a series of operation problems, and improve the transmission efficiency.

[0042] S300. Package the request information into a request message according to the data transmission protocol, write the request message into the control script, and send the request message to the network to be called through the control script.

[0043] The transmission of data between networks needs to follow a certain data transmission protocol. The data transmission protocol is a part of the data link layer and provides a mechanism for PGNs with 9 bytes or more of transmitted data. In this embodiment, HTTP is used as the data transmission protocol. This protocol is a hypertext transfer protocol for network transmission and file transfer between networks, between a network and a computer user, or between computer users, and plays a crucial role in computer security and network security. HTTP is one of the most widely used network protocols on the Internet. All WWW files must comply with this standard. HTTP is also an application layer protocol, which is a protocol for implementing a specific type of application and is implemented by an application program running in the user space. In this embodiment, the request information, the domain name and port of the network to be called, and the domain name and port of the connection requester are packaged into a request message in the form of the HTTP protocol. Use the echo function to write the request message into the control script, and then the request message can be sent to the network to be called through the established socket channel in the control script.

[0044] In an embodiment of the present invention, in step S300, the data transmission protocol is the HTTP protocol. Packaging the request information into a request message according to the data transmission protocol includes:

[0045] S310. Write the request information into the message entity of the HTTP according to the standard format of the HTTP protocol.

[0046] S320. Add the message header of the HTTP before the message entity to form the request message.

[0047] In this embodiment, when data is sent from the connection request side to the network to be connected according to the HTTP protocol, the data needs to be encapsulated into the form of a request message for transmission. When encapsulating, the message is divided into two parts: a message header and a message body. Among them, the message header is used to indicate the start of the message, and source port, destination port, and information such as the protocol version number being transmitted can be stored therein. The information to be transmitted to the network to be connected is stored in the message body. After writing the request message into the control script through the echo function, the control script, as a control party, sends the request message to the port of the network to be called according to the request method indicated in the request message through the established socket channel, thereby realizing the transmission of information. Among them, the request method refers to the specific method by which the network needs to process the request, including GET, POST, HEAD, PUT, etc. In this embodiment, the GET request method is used. This request method is used to retrieve information from a given server using a given URL, that is, to request data from a specified resource. It is biased towards the acquisition method, and most of the time, some parameters are given to the backend to obtain column data. Exemplarily, when the data transmission protocol is HTTP1.1n and the request method used is GET, the information transmission method is: echo -e "GET / HTTP / 1.1\n" >&13. Among them, 13 is the file descriptor of the control script, and the location of the control script can be quickly located through the file descriptor. It can be understood that the request method is not limited to the GET type described in this embodiment, and can also be other request methods such as POST, HEAD, PUT, etc., which are not limited herein.

[0048] S400. Receive the response information returned according to the request message and write it into the control script.

[0049] After receiving the request message, the network to be called will parse and process the request message to obtain the request information. Then, it will search for the corresponding data in the network according to the request information, write this data into the response body, then write the domain name of the connection request side into the destination IP address, and fill in other information in the message. After encapsulation, a response message is obtained. The response message stores the response information returned by the network to be called. The response message is sent to the control script through the socket channel according to the data transmission protocol, and this information is written into the control script. So that the information can be sent to the connection request side through the control script subsequently.

[0050] In an embodiment of the present invention, in step S400, the receiving of the response information returned according to the request message includes: determining whether a response message returned by the network to be called is received within a preset time; and when the response message is received, parsing the response message to extract the response information in the response message. In order to improve the data conveyor belt efficiency, it is necessary to set the data transfer time. By determining whether a response message returned by the network to be called is received within a preset time, the smoothness of the network during this period can be understood. If a response message is received within the preset time, it indicates that the network between the connection requester and the network to be called is smooth, and the response message can be parsed. By extracting the content of the message entity in the response message, the response information returned by the network to be connected can be obtained. This response information is the data returned by the network to be connected according to the request information sent by the connection requester.

[0051] Further, in an embodiment of the present invention, the receiving of the response information returned according to the request message includes:

[0052] S410. When the response message is not received within the preset time, resend the request message to the network to be called, and accumulate the message sending times until the response message is received within the preset time, or the message sending times are greater than a preset threshold;

[0053] S420. When the message sending times are greater than the preset threshold, use the connection error information as the response information and disconnect the socket channel with the network to be called.

[0054] Since the response message returned by the network to be connected can be divided into two situations. One is that the response message arrives within the predetermined time, and the response information can be obtained according to the response message. The other is that the response message still has not been received after exceeding the predetermined time, which indicates that there are problems such as blockage in the communication link between the network to be connected and the connection requester at this time, and it is necessary to resend the previous request message to the network to be called again. By accumulating the number of times of sending the message, when the number of times of repeatedly sending the message within the preset time reaches a certain threshold and the response message still has not been received, it is considered that the network is still in a blocked state and effective data transmission cannot be carried out. At this time, connection error information is generated, and the control script will use the connection error information as the response information and send it to the connection requester. When the connection requester receives this connection error information, it will automatically disconnect the communication channel with the network to be called and wait for a subsequent re-sending of the connection request to establish a communication channel. And if the response information is received within the set time, it indicates that the communication link is smooth at this time and data intercommunication can be carried out.

[0055] Further, in step S420, the disconnecting of the socket channel with the network to be called includes:

[0056] S4201. Send a close request message to the to-be-called network;

[0057] S4202. Receive the close waiting message sent back by the to-be-called network according to the close request message;

[0058] S4203. Receive the consent to close message sent back by the to-be-called network according to the close request message;

[0059] S4204. According to the consent to close message, send a close confirmation message to the to-be-called network and disconnect the socket channel with the to-be-called network.

[0060] When the connection requester needs to disconnect the communication channel with the to-be-called network, first, the connection requester will send a close request message to the to-be-called network through the control script to indicate to the to-be-called network that it needs to disconnect the communication channel between the two. At this time, if the to-be-called network still has data not transmitted completely, it will send a close waiting message to the connection requester to continue sending the untransmitted data to the connection requester. When the to-be-called network sends all the data required by the connection requester to the connection requester according to the request message, it will send a consent to close message to the connection requester. After receiving the consent to close message, the connection requester sends a close confirmation message back to the to-be-called network, thereby disconnecting the communication link between the two. By this way of disconnecting the connection through four-way handshake, the situation of disconnecting the connection when the data is not transmitted completely can be effectively avoided, and the accuracy of closing the socket channel is improved.

[0061] S500. Send the response message to the connection requester through the control script.

[0062] In this embodiment, by reading the response message sent by the called network from the control script, the specific content sent back by the called network according to the request message can be obtained. By sending the specific content to the connection requester through the control script, the connection between the connection requester and the port of the to-be-called network can be established, and the communication between the two can be realized.

[0063] Further, in an embodiment of the present invention, before creating a readable and writable control script in the kernel, it further includes:

[0064] Judge whether the to-be-called network is in the blacklist library according to the domain name of the to-be-called network;

[0065] If so, stop creating the control script;

[0066] If not, create the control script.

[0067] For network security considerations, it is not possible to connect the local connection requester to any port of the network to be called. Therefore, a blacklist library can be set up in advance. The blacklist library stores the domain names of the networks that cannot be connected and the corresponding port information. By matching the domain name of the network to be called currently with each domain name information in the blacklist library, it can be queried whether the network to be called is in the blacklist library. If the domain name of the network to be called matches one of the domain names in the blacklist library, it is considered that the network to be called is in the blacklist library, so it cannot be connected and the creation of the control script needs to be stopped. If the domain name of the network to be called does not match any of the domain names in the blacklist library, it is considered that the network to be called is secure and not in the blacklist library, and the control script can continue to be created through the exec function. Further, in an embodiment of the present invention, after stopping the creation of the control script, it further includes: sending a blacklist warning message to the connection requester. The warning message can be shown on the screen by presenting the domain name of the network to be called and indicating that it is blacklist information and access is prohibited, so as to remind the operator not to access the port of the network to be called continuously and ensure information security.

[0068] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.

[0069] In an embodiment, a network connection system is provided. The network connection system corresponds one-to-one with the network connection method in the above embodiment. As Figure 7 shown, the network connection system includes an information acquisition module 111, a socket communication module 112, an information sending module 113, an information receiving module 114, and a communication module 115. The detailed descriptions of each functional module are as follows:

[0070] The information acquisition module 111 is used to acquire a connection request, and the connection request includes the data transmission protocol and request information with the network to be called, as well as the address information of the network to be called;

[0071] The socket communication module 112 is used to create a readable and writable control script in the kernel, and establish a socket channel with the network to be called through the control script according to the address information and a preset communication protocol;

[0072] The information sending module 113 is used to encapsulate the request information into a request message according to the data transmission protocol, write the request message into the control script, and send the request message to the network to be called through the control script;

[0073] An information receiving module 114, configured to receive response information returned according to the request message and write it into the control script.

[0074] A communication module 115, configured to send the response information to the connection requester through the control script.

[0075] In one embodiment, the socket communication module 112 is specifically configured to:

[0076] In response to a trigger request, create a control script at a preset position in the kernel using the exec function, where the control script supports read and write operations, and the trigger request is automatically triggered after obtaining the address information of the network to be called, and the address information includes a domain name and a port.

[0077] According to the domain name of the network to be called, send a connection request to the port of the network to be called through the control file according to a preset communication protocol.

[0078] Receive a connection confirmation response sent by the port, and the control script sends a confirmation message to the port again to establish a socket channel with the network to be called.

[0079] In one embodiment, the socket communication module 112 is further configured to:

[0080] Judge whether the network to be called is in the blacklist library according to the domain name of the network to be called;

[0081] If so, stop creating the control script.

[0082] If not, create a control script.

[0083] In one embodiment, the socket communication module 112 is further configured to:

[0084] In response to a trigger request, create a control script at a preset position in the kernel using the exec function, where the control script supports read and write operations, and the trigger request is automatically triggered after obtaining the domain name and port of the network to be called;

[0085] According to the domain name and port of the network to be called, the control script sends a connection request to the port of the domain name through a preset communication protocol; where the communication protocol is the TCP / IP protocol;

[0086] Receive a connection confirmation response sent by the port, and the control script sends a confirmation message to the port again to establish a socket channel with the network to be called.

[0087] In one embodiment, the information sending module 113 is specifically configured to:

[0088] Write the request information into the message entity of the HTTP according to the specified format of the HTTP protocol;

[0089] Add the message header of the HTTP before the message entity to form the request message.

[0090] In one embodiment, the information receiving module 114 is specifically configured to:

[0091] Determine whether a response message returned by the to-be-invoked network is received within a preset time; and when the response message is received, parse the response message and extract the response information in the response message.

[0092] In one embodiment, the information receiving module 114 is further configured to:

[0093] When the response message is not received within the preset time, resend the request message to the to-be-invoked network and accumulate the message sending times until the response message is received within the preset time or the message sending times are greater than a preset threshold;

[0094] When the message sending times are greater than the preset threshold, use the connection error information as the response information and disconnect the socket channel with the to-be-invoked network.

[0095] In one embodiment, the information receiving module 114 is further configured to:

[0096] Send a close request message to the to-be-invoked network;

[0097] Receive the close waiting message returned by the to-be-invoked network according to the close request message;

[0098] Receive the consent to close message returned by the to-be-invoked network according to the close request message;

[0099] According to the consent to close message, send a close confirmation message to the to-be-invoked network and disconnect the socket channel with the to-be-invoked network.

[0100] The present invention provides a network connection system. By obtaining a connection request sent by a connection requester, the connection request includes a data transmission protocol and request information for a network to be called, as well as address information of the network to be called. And a readable and writable control script is created in the kernel. According to the address information and a preset communication protocol, a socket channel with the network to be called is established through the control script. Then, according to the data transmission protocol in the connection request, the request information is encapsulated into a request message, and the request message is written into the control script. The request message is sent to the network to be called through the control script. When receiving response information returned according to the request message, the response information is written into the control script. Finally, the response information is sent to the connection requester through the control script to establish a connection with a network port. In the present invention, for the phenomenon that the existing method of connecting to a network relies too much on port codes or application environments and thus cannot achieve fast invocation of external server ports. In view of the above problems, through the control script created by the exec function, the underlying code logic is invoked. According to the preset communication protocol, a communication channel with the network to be called is first established. Then, according to the data transmission protocol between the connection requester and the network to be called, the request information sent by the connection requester is sent to the network to be called along the established communication channel through the control script. When receiving the data returned by the network port, these data are sent to the connection requester, thus realizing the connection between the connection requester and the port. Thereby avoiding the problem that calling a network port relies too much on port codes or application environments and thus cannot achieve fast invocation of external server ports. Breaking through the bottleneck in the prior art that a network cannot be accessed without writing a port program, using the most basic and core exec command, and performing network requests by creating a readable and writable file. Achieving fast connection to a network port, solving the authentication when telnet or curl is disabled through the created control script, without excessive additional business logic wrapping, making the response more efficient.

[0101] For the specific limitations of the network connection system, reference can be made to the limitations on the network connection method in the above text, which will not be elaborated here. Each module in the above network connection system can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of a computer device in hardware form or be independent of it, or be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above respective modules.

[0102] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 8As shown in the figure. The computer device includes a processor, a memory, a network port, and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network port of the computer device is used to communicate with an external supplier end through a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the server side of a network connection method.

[0103] In one embodiment, a computer device is provided. The computer device can be a supplier end, and its internal structure diagram can be as Figure 9 As shown in the figure. The computer device includes a processor, a memory, a network port, a display screen, and an input system connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network port of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the supplier end side of a network connection method

[0104] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:

[0105] Obtain a connection request, where the connection request includes a data transfer protocol and request information for the network to be called, and address information of the network to be called;

[0106] Create a readable and writable control script in the kernel, and establish a socket channel with the network to be called through the control script according to the address information and a preset communication protocol;

[0107] Encapsulate the request information into a request message according to the data transfer protocol, write the request message into the control script, and send the request message to the network to be called through the control script;

[0108] Receive response information returned according to the request message and write it into the control script;

[0109] Send the response information to the connection requester through the control script.

[0110] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0111] Obtain a connection request, where the connection request includes a data transmission protocol and request information for the network to be called, as well as address information of the network to be called;

[0112] Create a readable and writable control script in the kernel, and establish a socket channel with the network to be called according to the address information and a preset communication protocol;

[0113] Encapsulate the request information into a request message according to the data transmission protocol, write the request message into the control script, and send the request message to the network to be called through the control script;

[0114] Receive response information returned according to the request message and write it into the control script;

[0115] Send the response information to the connection requester through the control script.

[0116] It should be noted that for the functions or steps that the above computer-readable storage medium or computer device can achieve, reference can be made to the relevant descriptions on the server side and the supplier side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.

[0117] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memories can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memories can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.

[0118] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above.

[0119] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A method for connecting a network, characterized in that, comprising: obtaining a connection request, where the connection request includes a data transmission protocol and request information for the network to be called, and address information of the network to be called; using the exec command to create a readable and writable control script in the kernel, and establishing a socket channel with the network to be called through the control script according to the address information and a preset communication protocol; encapsulating the request information into a request message according to the data transmission protocol, writing the request message into the control script, and using the established socket channel through the control script to send the request message to the network to be called; receiving response information returned according to the request message and writing it into the control script; sending the response information to the connection requester through the control script; wherein, the response message is sent to the control script through the socket channel according to the data transmission protocol and written into the control script; the response message stores the response information returned by the network to be called.

2. The method for connecting a network according to claim 1, characterized in that, the step of using the exec command to create a readable and writable control script in the kernel, and establishing a socket channel with the network to be called through the control script according to the address information and a preset communication protocol includes: in response to a trigger request, using the exec function to create a control script at a preset position in the kernel, the control script supports read and write operations, wherein the trigger request is automatically triggered after obtaining the address information of the network to be called, and the address information includes a domain name and a port; according to the domain name of the network to be called, sending a connection request to the port of the network to be called through the control script according to a preset communication protocol; wherein, the communication protocol is the TCP / IP protocol; receiving a connection confirmation response sent by the port, and the control script sending a confirmation message to the port again to establish a socket channel with the network to be called.

3. The method for connecting a network according to claim 1, characterized in that, before using the exec command to create a readable and writable control script in the kernel, further comprising: judging whether the network to be called is in a blacklist library according to the domain name of the network to be called; if so, stopping creating the control script; if not, creating the control script.

4. The method for connecting a network according to claim 1, characterized in that, the data transmission protocol is the HTTP protocol, and the step of encapsulating the request information into a request message according to the data transmission protocol includes: writing the request information into the message entity of the HTTP protocol according to the specification format of the HTTP protocol; adding a message header of the HTTP protocol before the message entity to form the request message.

5. The method for connecting a network according to claim 1, characterized in that, the step of receiving response information returned according to the request message includes: Determine whether a response message returned by the to-be-called network is received within a preset time; and when the response message is received, parse the response message to extract the response information in the response message.

6. The network connection method according to claim 5, wherein, receiving the response information returned according to the request message includes: when the response message is not received within the preset time, resend the request message to the to-be-called network and increment the message sending count until the response message is received within the preset time or the message sending count is greater than a preset threshold; when the message sending count is greater than the preset threshold, use the connection error information as the response information and disconnect the socket channel with the to-be-called network.

7. The network connection method according to claim 6, wherein, disconnecting the socket channel with the to-be-called network includes: sending a close request message to the to-be-called network; receiving a close waiting message returned by the to-be-called network according to the close request message; receiving an agreed-to-close message returned by the to-be-called network according to the close request message; according to the agreed-to-close message, send a close confirmation message to the to-be-called network and disconnect the socket channel with the to-be-called network.

8. A network connection system, wherein, the system includes: an information acquisition module, configured to acquire a connection request, where the connection request includes a data transmission protocol and request information for the to-be-called network, and address information of the to-be-called network; a socket communication module, configured to create a readable and writable control script in the kernel using the exec command, and establish a socket channel with the to-be-called network through the control script according to the address information and a preset communication protocol; an information sending module, configured to encapsulate the request information into a request message according to the data transmission protocol, write the request message into the control script, and send the request message to the to-be-called network through the established socket channel using the control script; an information receiving module, configured to receive the response information returned according to the request message and write it into the control script a communication module, configured to send the response information to the connection requester through the control script; wherein, the response message is sent to the control script through the socket channel according to the data transmission protocol and written into the control script; the response information returned by the to-be-called network is stored in the response message.

9. A computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein, when the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, on which a computer program is stored, wherein, when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Proxy connection method and proxy connection device

    CN109547567A