A TCP / UDP-based network communication connection method, system and device
By directly establishing a connection with the terminal using TCP/UDP networks, the cost and complexity issues caused by adding relay equipment to the central control system are resolved, and a simplified system setup and maintenance are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 广州市迪士普音响科技有限公司
- Filing Date
- 2023-10-17
- Publication Date
- 2026-04-21
AI Technical Summary
In existing technologies, in order to control terminals that only accept TCP/UDP network communication protocols, the central control system needs to add relay equipment, which leads to increased equipment costs, troublesome initial system setup, increased debugging costs, and difficulties in later maintenance.
By obtaining the configuration file and parsing the configuration information to obtain the terminal's IP address and port number, communication is established directly with the terminal using a TCP/UDP network. The terminal is then controlled according to control commands. Only one network cable is needed to connect the central control host and the terminal, eliminating the need for additional relay equipment.
It reduced equipment costs, simplified system setup and maintenance processes, and reduced debugging and maintenance costs.
Smart Images

Figure CN117675885B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a network communication connection method, system and device based on TCP / UDP. Background Technology
[0002] There are many communication protocols between devices, but TCP / UDP network communication protocols are still the mainstream. However, many central control systems on the market add one or more relay devices to control terminals that only accept TCP / UDP network communication protocols. These relay devices convert serial port protocols or other protocols to TCP / UDP network communication protocols to control the terminals. Therefore, existing technologies have the following problems: 1) The need to add relay devices increases equipment costs; 2) Initial system setup is cumbersome, increasing debugging costs; 3) Subsequent system maintenance is difficult, increasing maintenance costs. Summary of the Invention
[0003] In view of this, this application provides a network communication connection method, system and apparatus based on TCP / UDP, so as to enable communication with terminals that only accept TCP / UDP network communication protocols without adding additional relay equipment.
[0004] One aspect of this application provides a network communication connection method based on TCP / UDP, comprising:
[0005] Obtain a configuration file, which includes configuration information for one or more terminals and control commands for the terminals;
[0006] The configuration information in the configuration file is parsed to obtain the IP address and port number of the terminal;
[0007] Establish TCP / UDP network communication with the terminal using the IP address and port number;
[0008] Control the terminal according to the control command.
[0009] Optionally, obtaining the configuration file includes:
[0010] Receive configuration files uploaded by users via PC hosts.
[0011] Optionally, the configuration file may also include a single-step command module, a combined command module, a distributed sub-board configuration parameter module, a timer configuration module, and a keyword matching configuration module;
[0012] The method further includes:
[0013] Use the configuration file as the current configuration file and read the version number of the current configuration file;
[0014] If the version number of the current configuration file is higher than the version number of an existing configuration file, then clear the memory linked list container.
[0015] Read the root node of the current configuration file and read each child node under each root node in a loop to obtain multiple single-step commands, multiple combined commands, multiple distributed sub-board configuration parameters, multiple time point configuration parameters, and multiple keyword matching configuration parameters;
[0016] The multiple single-step commands, multiple combined commands, multiple distributed sub-board configuration parameters, multiple time point configuration parameters, and multiple keyword matching configuration parameters are categorized and stored in the memory linked list container for later invocation.
[0017] Optionally, establishing TCP / UDP network communication with the terminal via the IP address and port number includes:
[0018] Create a socket file descriptor for a TCP / UDP network;
[0019] Configure the port multiplexing of the socket file descriptor so that after disconnecting from the terminal, reconnection can be performed without port occupation;
[0020] Set the size of the receive and send buffers of the socket file descriptor to reduce memory usage pressure;
[0021] Based on the IP address and port number, a connection is requested to be established with the terminal using the socket file descriptor;
[0022] Upon receiving a confirmation connection from the terminal, TCP / UDP network communication with the terminal is established.
[0023] Optionally, controlling the terminal according to the control command includes:
[0024] When a trigger command uploaded by a user via a PC host is received, the terminal is controlled according to the control command; the trigger command includes the single-step command and / or the combined command;
[0025] Alternatively, when the conditions of the time point configuration parameters are met, the terminal is controlled according to the control command;
[0026] Alternatively, when establishing TCP / UDP network communication with the terminal, the terminal can be controlled immediately according to the control command.
[0027] Another aspect of this application provides a network communication connection system based on TCP / UDP, including: a PC host, a central control host, and one or more terminals;
[0028] The PC host is connected to the central control host via a network, and the central control host is connected to each of the terminals via a network cable.
[0029] The PC host is used to generate configuration files and / or trigger commands in response to user operations, and upload the configuration files and / or trigger commands to the central control host;
[0030] The central control host is used to execute a network communication connection method based on TCP / UDP as described in any one of claims 1 to 5;
[0031] The terminal is used to perform corresponding operations in response to the control of the central control host.
[0032] Optionally, the terminal includes a motor for controlling the curtains, a host computer for controlling the lights, a camera device, or a central air conditioner;
[0033] When the terminal is the motor controlling the curtain, the terminal is used to respond to the control of the central control host to perform at least one of the curtain opening action, closing action, or stopping action;
[0034] When the terminal is the host computer controlling the light, the terminal is used to respond to the control of the central control host to perform at least one of the following actions: turning the light on, turning it off, or flashing the light.
[0035] When the terminal is the camera device, the terminal is used to respond to the control of the central control host to perform at least one of the following actions: camera up / down / left / right movement, close-up movement, telephoto movement, or return to a preset point.
[0036] When the terminal is the central air conditioner, the terminal is used to respond to the control of the central control host to perform at least one of the following actions: turning the central air conditioner on or off, switching modes, adjusting the temperature, or adjusting the fan speed.
[0037] Another aspect of this application provides a network communication connection device based on TCP / UDP, comprising:
[0038] The first unit is used to obtain a configuration file, which includes configuration information of one or more terminals and control commands for the terminals;
[0039] The second unit is used to parse the configuration information in the configuration file to obtain the IP address and port number of the terminal;
[0040] The third unit is used to establish TCP / UDP network communication with the terminal through the IP address and port number;
[0041] The fourth unit is used to control the terminal according to the control command.
[0042] Another aspect of this application provides an electronic device, including a processor and a memory;
[0043] The memory is used to store programs;
[0044] The processor executes the program to implement the TCP / UDP-based network communication connection method.
[0045] Another aspect of this application provides a computer-readable storage medium storing a program that is executed by a processor to implement the TCP / UDP-based network communication connection method.
[0046] This application also discloses a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of an electronic device can read the computer instructions from the computer-readable storage medium and execute the computer instructions, causing the electronic device to perform the method described above.
[0047] This application first obtains a configuration file, which includes configuration information for one or more terminals and control commands for those terminals. Then, it parses the configuration information in the configuration file to obtain the terminal's IP address and port number. Next, it establishes TCP / UDP network communication with the terminal using the IP address and port number. Finally, it controls the terminal according to the control commands. This application eliminates the need for additional relay equipment; it only requires the IP address and port number to establish TCP / UDP network communication with the terminal, thus reducing equipment costs. Furthermore, this application allows for faster system setup in the early stages, reducing debugging costs, and simplifies later system maintenance, reducing maintenance costs. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1 A flowchart illustrating a TCP / UDP-based network communication connection method provided in an embodiment of this application;
[0050] Figure 2 An example structural diagram of a TCP / UDP-based network communication connection system provided in this application embodiment;
[0051] Figure 3 An example flowchart of a TCP / UDP-based network communication connection method provided in this application embodiment;
[0052] Figure 4 This is a structural block diagram of a TCP / UDP-based network communication connection device provided in an embodiment of this application. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0054] It should be noted that although functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart.
[0055] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0057] Reference Figure 1 This application provides a network communication connection method based on TCP / UDP, which can be applied to a central control host. The method includes steps S100 to S130, as follows:
[0058] S100: Obtain the configuration file, which includes configuration information for one or more terminals and control commands for the terminals.
[0059] Specifically, the configuration file in this embodiment can be an XML file, i.e., an XML configuration file. The configuration information in the file can include the IP address and port number of each terminal. The purpose of the configuration information is that when the embedded software module of the TCP / UDP network communication protocol creates a socket connection with the terminal, it needs to bind the IP address and port number of the terminal and transmit data to the terminal through the socket file descriptor.
[0060] The specific control commands can perform depend on the type of device the terminal is. For example, if the terminal controls the motor of a curtain, the control commands can control the motor's operation to open, close, or stop the curtains. For example, if the terminal is a host computer controlling lights, the control commands can control the lights to turn on, off, or flash. For example, if the terminal is a camera device, the control commands can control the camera's movement (up, down, left, right), zoom in, zoom out, and return to a preset point.
[0061] As a further implementation, step S100 may include:
[0062] Receive configuration files uploaded by users via PC hosts.
[0063] Specifically, users can configure the configuration file on the logic editing software of the PC host, and then the PC host will upload the configuration file to the central control host.
[0064] S110: Parse the configuration information in the configuration file to obtain the IP address and port number of the terminal.
[0065] Specifically, in this embodiment, the configuration information in the XML format configuration file is parsed to obtain the IP address and port number of each terminal contained in the configuration information.
[0066] Furthermore, the configuration file in this embodiment may also include a single-step command module, a combined command module, a distributed sub-board configuration parameter module, a timed point configuration module, and a keyword matching configuration module.
[0067] Therefore, in this embodiment, parsing the configuration file may further include steps S111 to S114:
[0068] S111: Use the configuration file as the current configuration file and read the version number of the current configuration file.
[0069] Specifically, the central control unit can open the XML format configuration file in read-only mode and read the version number of the newly uploaded XML configuration file.
[0070] S112: If the version number of the current configuration file is higher than the version number of the existing configuration file, then clear the memory linked list container.
[0071] Specifically, the central control unit can determine whether the version number is higher than the version number of the old XML configuration file. If so, it parses the current configuration file and clears the memory linked list container to prepare for storing data from each module; otherwise, it does not parse the current configuration file.
[0072] S113: Read the root node of the current configuration file and read each child node under each root node in a loop to obtain multiple single-step commands, multiple combined commands, multiple distributed sub-board configuration parameters, multiple time point configuration parameters, and multiple keyword matching configuration parameters.
[0073] Specifically, the root node of the XML configuration file is read, which is the entry point for reading all data. Then, each child node under the root node is read in a loop. Each child node is the entry point for reading parameter module data. Reading the child nodes of the child nodes in a loop is equivalent to reading single-step commands, combined commands, sub-board configuration parameters, timer configuration parameters, and keyword matching configuration parameters.
[0074] S114: The multiple single-step commands, multiple combined commands, multiple distributed sub-board configuration parameters, multiple time point configuration parameters, and multiple keyword matching configuration parameters are classified and stored in the memory linked list container for later invocation.
[0075] Specifically, the data read in step S113 is categorized and stored in a memory linked list container to await invocation. Then, the XML configuration file is closed, and the parsing step is exited.
[0076] S120: Establish TCP / UDP network communication with the terminal using the IP address and port number.
[0077] Specifically, in this embodiment, the central control host and the terminal are connected via a network cable. The central control host can quickly create TCP / UDP network communication with the terminal based on the IP address and port number provided in the configuration file.
[0078] As a further implementation, step S120 may include steps S121 to S125:
[0079] S121: Create a socket file descriptor for a TCP / UDP network.
[0080] Specifically, the central control host creates a socket file descriptor for the TCP / UDP network. This socket file descriptor is crucial for the central control host to receive and send data after establishing a connection with the terminal.
[0081] S122: Configure port multiplexing for the socket file descriptor so that reconnection can be performed without port occupation after disconnection from the terminal.
[0082] Specifically, the central control host sets up port reuse for the socket file descriptor to ensure that after disconnecting from the terminal, it can reconnect without port occupation.
[0083] S123: Set the size of the receive and send buffer of the socket file descriptor to reduce memory usage pressure.
[0084] Specifically, the central control host sets the size of the receive and send buffer of the socket file descriptor to reduce the pressure on memory usage. For example, in this embodiment, the size of the buffer can be 1024*1024 bytes.
[0085] S124: Request to establish a connection with the terminal using the socket file descriptor based on the IP address and port number.
[0086] Specifically, the central control host calls the terminal's IP address and port number stored in the memory linked list container, and requests to establish a connection with the terminal using the socket file descriptor based on the IP address and port number.
[0087] S125: When a confirmation connection is received from the terminal, TCP / UDP network communication with the terminal is established.
[0088] Specifically, once the terminal replies with a connection confirmation, the control host can establish TCP / UDP network communication with the terminal.
[0089] S130: Control the terminal according to the control command.
[0090] Specifically, the central control unit can control the terminal to perform corresponding operations after establishing TCP / UDP network communication according to control commands.
[0091] As a further implementation, step S130 may include:
[0092] When a trigger command uploaded by a user via a PC host is received, the terminal is controlled according to the control command; the trigger command includes the single-step command and / or the combined command;
[0093] Alternatively, when the conditions of the time point configuration parameters are met, the terminal is controlled according to the control command;
[0094] Alternatively, when establishing TCP / UDP network communication with the terminal, the terminal can be controlled immediately according to the control command.
[0095] Specifically, users can use the logic editing software on the PC host to trigger the central control host to issue commands (commands refer to single-step commands and combined commands stored in the memory linked list container) to control the terminal.
[0096] Moreover, the control commands in this embodiment do not necessarily need to be manually triggered. The central control host also has a timed trigger function and an immediate trigger function. Timed triggering can be set when configuring the XML file. For example, in the following application scenario: a company holds a group morning meeting at 8:00 am every Monday, so a timed point of 7:50 am can be set. When the timed point is reached, the trigger command is executed to control the equipment in the venue, including but not limited to: turning on the lights, turning on the air conditioner, turning on the sound amplification equipment, turning on the audio-visual equipment, etc.
[0097] After receiving an instruction, the terminal executes the control command and performs terminal control operations. For example, 1: the terminal controls the motor of the curtains, and the terminal's response is to open, close, or stop the curtains; 2: the terminal is a host computer that controls the lights, and the terminal's response is to turn the lights on, off, or flash; 3: the terminal is a camera device, and the terminal's response is to move the camera up, down, left, and right, zoom in, zoom out, or return to the preset point; 4: the terminal is a central air conditioning system, and the terminal's response is to turn the central air conditioning system on and off, switch modes, adjust the temperature, and adjust the fan speed.
[0098] The TCP / UDP-based network communication connection method provided in this application enables the central control host to control one or more terminals with only one network cable connection, without the need for other relay devices.
[0099] This application also provides a TCP / UDP-based network communication connection system, which includes: a PC host, a central control host, and one or more terminals;
[0100] The PC host is connected to the central control host via a network, and the central control host is connected to each of the terminals via a network cable.
[0101] The PC host is used to generate configuration files and / or trigger commands in response to user operations, and upload the configuration files and / or trigger commands to the central control host;
[0102] The central control host is used to execute the above-mentioned TCP / UDP-based network communication connection method;
[0103] The terminal is used to perform corresponding operations in response to the control of the central control host.
[0104] Reference Figure 2This embodiment provides an example structural diagram of a network communication connection system based on TCP / UDP.
[0105] The terminal in this embodiment can include various types of devices, meaning the central control host can simultaneously control different types of terminals. Further, the terminal includes a motor for controlling curtains, a host computer for controlling lights, a camera device, or a central air conditioner;
[0106] When the terminal is the motor controlling the curtain, the terminal is used to respond to the control of the central control host to perform at least one of the curtain opening action, closing action, or stopping action;
[0107] When the terminal is the host computer controlling the light, the terminal is used to respond to the control of the central control host to perform at least one of the following actions: turning the light on, turning it off, or flashing the light.
[0108] When the terminal is the camera device, the terminal is used to respond to the control of the central control host to perform at least one of the following actions: camera up / down / left / right movement, close-up movement, telephoto movement, or return to a preset point.
[0109] When the terminal is the central air conditioner, the terminal is used to respond to the control of the central control host to perform at least one of the following actions: turning the central air conditioner on or off, switching modes, adjusting the temperature, or adjusting the fan speed.
[0110] To facilitate a clearer understanding of this application, a complete optional example will be used to illustrate it below.
[0111] Reference Figure 3 This embodiment provides an example flowchart of a TCP / UDP-based network communication connection method. In this embodiment, the TCP / UDP-based network communication connection method provided in this application can be encapsulated as an embedded software module of the central control host, i.e., a virtual board.
[0112] Specifically, the user edits the terminal's configuration information and control commands on the PC host's logic editing software.
[0113] The configuration information may specifically include the terminal's IP address and port number. The purpose of this configuration information is that when the embedded software module of the TCP / UDP network communication protocol establishes a socket connection with the terminal, it needs to bind the terminal's IP address and port number, and then transmit data to the terminal through this socket file descriptor.
[0114] The specific control commands can perform depend on the type of device the terminal is. Example 1: If the terminal controls a curtain motor, the control commands can control the motor's operation, enabling operations such as opening, closing, and stopping the curtains. Example 2: If the terminal is a host computer controlling lights, the control commands can control the lights to turn on, off, or flash. Example 3: If the terminal is a camera device, the control commands can control the camera's movement (up, down, left, right), zoom in, zoom out, and return to a preset point.
[0115] Then, the XML configuration file is uploaded to the central control host. The embedded software modules of the central control host's TCP / UDP and network communication protocols will parse this XML configuration file. This XML configuration file may include: single-step command module, combined command module, distributed sub-board configuration parameter module, timer configuration module, and keyword matching configuration module.
[0116] Parsing the XML configuration file involves the following steps: Step 1: Open the XML configuration file in read-only mode, read the version number of the newly uploaded XML configuration file, and determine if the version number is higher than that of the old XML configuration file. If so, parse it; otherwise, do not parse it. Step 2: Clear the memory linked list container to prepare for storing data from each module. Step 3: Read the root node of the XML configuration file. The root node is the entry point for reading all data. Step 4: Loop through the child nodes of the root node. Each child node is the entry point for reading parameter module data. Step 5: Loop through the child nodes of the child nodes, which is equivalent to reading single-step commands, combined commands, sub-board configuration parameters, and timer configuration parameters. Step 6: Store the data read in Step 5 into the memory linked list container in categories, ready for use. Step 7: Close the XML configuration file and exit parsing.
[0117] The central control host then quickly establishes TCP / UDP network communication with the terminal based on the IP address and port number provided in the configuration file. The specific steps include: Step 1: Creating a TCP / UDP network socket file descriptor, which is crucial for receiving and sending data. Step 2: Setting port reuse for the socket file descriptor to ensure reconnection without port congestion after disconnection. Step 3: Setting the size of the socket file descriptor's receive and send buffers to reduce memory usage; the buffer size is 1024*1024 bytes. Step 4: Retrieving the terminal's IP address and port number stored in the memory linked list container, and requesting a connection with the terminal using the socket file descriptor. Step 5: The terminal replies with a connection confirmation, thus establishing the communication connection between the TCP / UDP network communication virtual card and the terminal.
[0118] Then, the user triggers the central control unit to issue commands (commands refer to single-step commands and combined commands stored in the memory linked list container) via the logic editing software on the PC host to control the terminal through the TCP / UDP network protocol. It should be noted that this embodiment does not necessarily require manual triggering; the central control unit also has a timer function, which can be set to trigger at a set time when configuring the XML file. Application scenario: A company holds a weekly morning meeting at 8:00 AM every Monday. A timer can be set at 7:50 AM. At the set time, a command is triggered to control equipment in the venue, including but not limited to: turning on lights, air conditioning, public address systems, and audio-visual equipment.
[0119] After receiving an instruction, the terminal executes the control command and performs terminal control operations. For example, 1: the terminal controls the motor of the curtains, and the terminal's response is to open, close, or stop the curtains; 2: the terminal is a host computer that controls the lights, and the terminal's response is to turn the lights on, off, or flash; 3: the terminal is a camera device, and the terminal's response is to move the camera up, down, left, and right, zoom in, zoom out, or return to the preset point; 4: the terminal is a central air conditioning system, and the terminal's response is to turn the central air conditioning system on and off, switch modes, adjust the temperature, and adjust the fan speed.
[0120] With the embedded software module of TCP / UDP network communication protocol, the central control host and the terminal only need to be connected by a single network cable. No other relay equipment is required to enable the central control host to control one or more terminals.
[0121] This application embodiment embeds a virtual board supporting TCP / UDP network communication protocols within the central control host program. The virtual board directly controls terminals that only accept TCP / UDP network communication protocols, thereby eliminating all the negative impacts of adding relay devices. This application embodiment has the following beneficial effects:
[0122] 1. No additional transfer equipment is required; it is purely software-based, further reducing equipment costs.
[0123] 2. Initial setup only requires providing the terminal's IP address and port number to add a TCP / UDP network communication virtual card. The operation is simple and easy to learn.
[0124] 3. If a fault occurs, simply check whether there is an IP address conflict between the terminals or whether the network cable is damaged. The problem can be easily located without the need for technical personnel, making maintenance very convenient.
[0125] Reference Figure 4 This application provides a network communication connection device based on TCP / UDP, including:
[0126] The first unit is used to obtain a configuration file, which includes configuration information of one or more terminals and control commands for the terminals;
[0127] The second unit is used to parse the configuration information in the configuration file to obtain the IP address and port number of the terminal;
[0128] The third unit is used to establish TCP / UDP network communication with the terminal through the IP address and port number;
[0129] The fourth unit is used to control the terminal according to the control command.
[0130] The specific implementation of this network communication connection device is basically the same as the specific embodiment of the network communication connection method described above, and will not be repeated here.
[0131] This application also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the above-described network communication connection method.
[0132] Specifically, electronic devices can be user terminals or servers.
[0133] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described network communication connection method.
[0134] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0135] This application also discloses a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of an electronic device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the electronic device to perform... Figure 1 The method shown.
[0136] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this application are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is changed and sub-operations described as part of a larger operation are executed independently.
[0137] Furthermore, although this application is described in the context of functional modules, it should be understood that, unless otherwise stated, one or more of the described functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding this application. Rather, given the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed herein, the actual implementation of the module will be understood within the scope of conventional technology for an engineer. Therefore, those skilled in the art can implement the application set forth in the claims using ordinary techniques without excessive experimentation. It is also understood that the specific concepts disclosed are merely illustrative and not intended to limit the scope of this application, which is determined by the full scope of the appended claims and their equivalents.
[0138] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0139] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0140] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0141] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0142] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0143] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
[0144] The above is a detailed description of the preferred embodiments of this application, but this application is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application, and these equivalent modifications or substitutions are all included within the scope defined by the claims of this application.
Claims
1. A network communication connection method based on TCP / UDP, characterized in that, The method is applied to a central control unit, and the method includes: Obtain a configuration file, which includes configuration information for one or more terminals and control commands for the terminals; The configuration information in the configuration file is parsed to obtain the IP address and port number of the terminal; Establish TCP / UDP network communication with the terminal using the IP address and port number; Control the terminal according to the control command; The step of establishing TCP / UDP network communication with the terminal using the IP address and port number includes: Create a socket file descriptor for a TCP / UDP network; wherein, the socket file descriptor is used to receive and send data after establishing a connection with the terminal; Configure the port multiplexing of the socket file descriptor so that after disconnecting from the terminal, reconnection can be performed without port occupation; Set the size of the receive and send buffers of the socket file descriptor to reduce memory usage pressure; The process involves using the socket file descriptor to request and establish a connection with the terminal based on the IP address and port number; specifically, it involves calling the terminal's IP address and port number stored in the memory linked list container, and then using the socket file descriptor to request and establish a connection with the terminal based on the IP address and port number. Upon receiving a confirmation connection from the terminal, TCP / UDP network communication with the terminal is established. The configuration file also includes a single-step command module, a combined command module, a distributed sub-board configuration parameter module, a timed point configuration module, and a keyword matching configuration module. The method further includes: Use the configuration file as the current configuration file and read the version number of the current configuration file; If the version number of the current configuration file is higher than the version number of an existing configuration file, then clear the memory linked list container. Read the root node of the current configuration file and read each child node under each root node in a loop to obtain multiple single-step commands, multiple combined commands, multiple distributed sub-board configuration parameters, multiple time point configuration parameters, and multiple keyword matching configuration parameters; The multiple single-step commands, multiple combined commands, multiple distributed sub-board configuration parameters, multiple time point configuration parameters, and multiple keyword matching configuration parameters are categorized and stored in the memory linked list container for later invocation. In this process, the user triggers the central control host to issue instructions to control the terminal through the TCP / UDP network protocol by operating the logic editing software on the PC host; the instructions refer to the single-step commands and combined commands stored in the memory linked list container.
2. The network communication connection method based on TCP / UDP according to claim 1, characterized in that, The process of obtaining the configuration file includes: Receive configuration files uploaded by users via PC hosts.
3. The network communication connection method based on TCP / UDP according to claim 1, characterized in that, The step of controlling the terminal according to the control command includes: When a trigger command uploaded by a user via a PC host is received, the terminal is controlled according to the control command; the trigger command includes the single-step command and / or the combined command; Alternatively, when the conditions of the time point configuration parameters are met, the terminal is controlled according to the control command; Alternatively, when establishing TCP / UDP network communication with the terminal, the terminal can be controlled immediately according to the control command.
4. A network communication connection system based on TCP / UDP, characterized in that, include: PC host, central control host and one or more terminals; The PC host is connected to the central control host via a network, and the central control host is connected to each of the terminals via a network cable. The PC host is used to generate configuration files and / or trigger commands in response to user operations, and upload the configuration files and / or trigger commands to the central control host; The central control host is used to execute a TCP / UDP-based network communication connection method as described in any one of claims 1 to 3; The terminal is used to perform corresponding operations in response to the control of the central control host.
5. A network communication connection system based on TCP / UDP according to claim 4, characterized in that, The terminal includes a motor for controlling the curtains, a host computer for controlling the lights, a camera device, or a central air conditioner; When the terminal is the motor controlling the curtain, the terminal is used to respond to the control of the central control host to perform at least one of the curtain opening action, closing action, or stopping action; When the terminal is the host computer controlling the light, the terminal is used to respond to the control of the central control host to perform at least one of the following actions: turning the light on, turning it off, or flashing the light. When the terminal is the camera device, the terminal is used to respond to the control of the central control host to perform at least one of the following actions: camera up / down / left / right movement, close-up movement, telephoto movement, or return to a preset point. When the terminal is the central air conditioner, the terminal is used to respond to the control of the central control host to perform at least one of the following actions: turning the central air conditioner on or off, switching modes, adjusting the temperature, or adjusting the fan speed.
6. A network communication connection device based on TCP / UDP, characterized in that, The device is applied to a central control unit, and the device includes: The first unit is used to obtain a configuration file, which includes configuration information of one or more terminals and control commands for the terminals; The second unit is used to parse the configuration information in the configuration file to obtain the IP address and port number of the terminal; The third unit is used to establish TCP / UDP network communication with the terminal through the IP address and port number; The fourth unit is used to control the terminal according to the control command; The step of establishing TCP / UDP network communication with the terminal using the IP address and port number includes: Create a socket file descriptor for a TCP / UDP network; wherein, the socket file descriptor is used to receive and send data after establishing a connection with the terminal; Configure the port multiplexing of the socket file descriptor so that after disconnecting from the terminal, reconnection can be performed without port occupation; Set the size of the receive and send buffers of the socket file descriptor to reduce memory usage pressure; The process involves using the socket file descriptor to request and establish a connection with the terminal based on the IP address and port number; specifically, it involves calling the terminal's IP address and port number stored in the memory linked list container, and then using the socket file descriptor to request and establish a connection with the terminal based on the IP address and port number. Upon receiving a confirmation connection from the terminal, TCP / UDP network communication with the terminal is established. The configuration file also includes a single-step command module, a combined command module, a distributed sub-board configuration parameter module, a timed point configuration module, and a keyword matching configuration module. Use the configuration file as the current configuration file and read the version number of the current configuration file; If the version number of the current configuration file is higher than the version number of an existing configuration file, then clear the memory linked list container. Read the root node of the current configuration file and read each child node under each root node in a loop to obtain multiple single-step commands, multiple combined commands, multiple distributed sub-board configuration parameters, multiple time point configuration parameters, and multiple keyword matching configuration parameters; The multiple single-step commands, multiple combined commands, multiple distributed sub-board configuration parameters, multiple time point configuration parameters, and multiple keyword matching configuration parameters are categorized and stored in the memory linked list container for later invocation. In this process, the user triggers the central control host to issue instructions to control the terminal through the TCP / UDP network protocol by operating the logic editing software on the PC host; the instructions refer to the single-step commands and combined commands stored in the memory linked list container.
7. An electronic device, characterized in that, Including the processor and memory; The memory is used to store programs; The processor executes the program to implement a TCP / UDP-based network communication connection method as described in any one of claims 1 to 3.
8. A computer-readable storage medium, characterized in that, The storage medium stores a program, which is executed by a processor to implement a TCP / UDP-based network communication connection method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Method and system for data interaction between home server and plurality of terminals
CN103236960A
Data transmission method, device and system
CN104519129A