Unix socket-based communication optimization method, system and terminal

By dynamically adjusting macro definitions and communication control files in Unix socket communication, the shortcomings of Unix socket communication configuration and verification in the prior art are solved, and efficient communication between WiFi HAL and WPA are achieved and system stability improvements are achieved.

CN119597495APending Publication Date: 2025-03-11深圳开鸿数字产业发展有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411058266.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

The prior art has shortcomings in configuring and verifying Unix socket communications, and lacks system optimization solutions, resulting in low communication efficiency and poor stability.

Method used

By defining selection variables in the communication configuration file, dynamically modifying the macro definition configuration, adjusting the communication control file to support Unix socket paths, and generating initialization configurations to adjust the startup script, ultimately controlling the client and server to conduct Unix socket communication.

Benefits of technology

It realizes efficient communication between WiFi HAL and WPA, simplifies the system architecture, improves communication performance and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597495A_ABST
    Figure CN119597495A_ABST
Patent Text Reader

Abstract

The invention discloses a Unix socket-based communication optimization method, a Unix socket-based communication optimization system and a terminal, and the Unix socket-based communication optimization method comprises the steps: defining a selection variable in a communication configuration file, and modifying a macro definition according to the selection variable to obtain macro definition configuration; modifying a communication control file to obtain a target communication control file, and adjusting control interface paths of the client and the server according to the target communication control file and the macro definition configuration; generating initial configuration according to the target communication control file, and adjusting a preset starting script according to the initial configuration to obtain starting configuration; and controlling the client side and the server side to carry out Unix socket communication according to the starting configuration. By providing the standard local communication interface, efficient communication between the WiFi HAL and the WPA is realized, the system architecture is simplified, and the communication performance and the system stability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of file processing, and in particular to a communication optimization method, system, terminal and computer-readable storage medium based on Unix socket. Background Art

[0002] With the rapid development of modern computing technology, inter-process communication (IPC) has become a key technology in multi-process applications. The inter-process communication mechanism allows data exchange and coordination between different processes, thereby achieving more complex and efficient system operations. In order to improve communication efficiency and reduce communication delays, the industry has gradually paid attention to the application of Unix sockets. Unix sockets have the advantages of low latency and low resource consumption. In Unix-like operating systems, commonly used inter-process communication methods include named pipes (FIFO, First-In First-Out), message queues, shared memory, semaphores, etc. Especially in the implementation of wireless network communication, the communication between WiFi HAL (Hardware Abstraction Layer) and WPA (Wi-Fi Protected Access) usually adopts a custom communication protocol or User Datagram Protocol (UDP).

[0003] However, traditional communication methods have some limitations and shortcomings in practical applications. Configuration and application require specific optimization and adjustment of the system. Developing and maintaining complex custom communication protocols not only increases the complexity of the system, but also easily introduces potential security vulnerabilities and compatibility issues. Although UDP is a connectionless protocol suitable for fast data transmission, it lacks reliability and order guarantees, and is prone to packet loss or retransmission in complex network environments, affecting the stability and performance of communication.

[0004] Therefore, the prior art still needs to be improved and developed. Summary of the invention

[0005] The main purpose of the present invention is to provide a communication optimization method, system, terminal and computer-readable storage medium based on Unix sockets, aiming to solve the technical problem that the prior art still has deficiencies in configuring and verifying Unix socket communications and lacks a system optimization solution during system configuration, initialization and startup.

[0006] To achieve the above object, the present invention provides a communication optimization method based on Unix sockets, and the communication optimization method based on Unix sockets comprises the following steps:

[0007] Defining a selection variable in a communication configuration file, and modifying a macro definition according to the selection variable to obtain a macro definition configuration;

[0008] Modify the communication control file to obtain a target communication control file, and adjust the control interface paths of the client and the server according to the target communication control file and the macro definition configuration;

[0009] Generate an initialization configuration according to the target communication control file, and adjust a preset startup script according to the initialization configuration to obtain a startup configuration;

[0010] According to the startup configuration, the client and the server are controlled to perform Unix socket communication.

[0011] Optionally, the communication optimization method based on Unix sockets, wherein the selection variable is defined in the communication configuration file, and the macro definition is modified according to the selection variable to obtain the macro definition configuration, specifically includes:

[0012] Defining a selection variable of a Unix socket communication mode and a value of the selection variable in a communication configuration file, and selecting a different communication mode according to the value of the selection variable;

[0013] In the compiled file, the macro definition is dynamically modified during the compilation process according to the value of the variable to obtain the macro definition configuration.

[0014] Optionally, the communication optimization method based on Unix socket, wherein the modifying of the communication control file to obtain the target communication control file, and adjusting the control interface paths of the client and the server according to the target communication control file and the macro definition configuration, specifically includes:

[0015] Add the definition of Unix socket path in the communication control file to get the target communication control file;

[0016] Modifying the control interface paths of the client and the server to the Unix socket paths according to the target communication control file and the macro definition configuration;

[0017] The control interface path is verified and access permissions are configured.

[0018] Optionally, in the communication optimization method based on Unix sockets, generating an initialization configuration according to the target communication control file specifically includes:

[0019] According to the target communication control file, defining initialization functions in the client and the server;

[0020] An initialization process is selected according to the initialization function and initialization parameters are set, and the initialization process and the initialization parameters are combined to generate an initialization configuration.

[0021] Optionally, the communication optimization method based on Unix sockets, wherein adjusting a preset startup script according to the initialization configuration to obtain a startup configuration, specifically includes:

[0022] Constructing a startup instruction according to the initialization parameters;

[0023] The preset startup script is modified, the startup instruction is written into the preset startup script, and the execution permission of the startup script is set to obtain the startup configuration.

[0024] Optionally, the communication optimization method based on Unix socket, wherein the step of controlling the client and the server to perform Unix socket communication according to the startup configuration, specifically includes:

[0025] Starting the client and the server according to the startup configuration, and initializing the Unix socket path between the client and the server;

[0026] A communication test is performed on the client and the server, and if the test passes, Unix socket communication between the client and the server is established.

[0027] Optionally, the communication optimization method based on Unix sockets, wherein the step of controlling the client and the server to perform Unix socket communication according to the startup configuration, further comprises:

[0028] Verifying the macro definition configuration by analyzing the communication configuration file;

[0029] Verifying the initialization configuration by analyzing the initialization logs of the client and the server;

[0030] Run the startup test script to verify the startup configuration.

[0031] In addition, to achieve the above object, the present invention also provides a communication optimization system based on Unix sockets, wherein the communication optimization system based on Unix sockets comprises:

[0032] A macro definition module, used for defining selection variables in a communication configuration file, and modifying the macro definition according to the selection variables to obtain a macro definition configuration;

[0033] A communication control module, used for modifying a communication control file to obtain a target communication control file, and adjusting the control interface paths of the client and the server according to the target communication control file and the macro definition configuration;

[0034] An initialization module, used to generate an initialization configuration according to the target communication control file, and adjust a preset startup script according to the initialization configuration to obtain a startup configuration;

[0035] The communication module is used to control the client and the server to perform Unix socket communication according to the startup configuration.

[0036] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and a Unix socket-based communication optimization program stored in the memory and executable on the processor, wherein the Unix socket-based communication optimization program implements the steps of the Unix socket-based communication optimization method as described above when executed by the processor.

[0037] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a communication optimization program based on a Unix socket, and when the communication optimization program based on a Unix socket is executed by a processor, the steps of the communication optimization method based on a Unix socket as described above are implemented.

[0038] In the present invention, a selection variable is defined in a communication configuration file, and a macro definition is modified according to the selection variable to obtain a macro definition configuration; a communication control file is modified to obtain a target communication control file, and the control interface paths of a client and a server are adjusted according to the target communication control file and the macro definition configuration; an initialization configuration is generated according to the target communication control file, and a preset startup script is adjusted according to the initialization configuration to obtain a startup configuration; and according to the startup configuration, the client and the server are controlled to perform Unix socket communication. The present invention realizes efficient communication between WiFi HAL and WPA by providing a standard local communication interface, simplifies the system architecture, and improves communication performance and system stability. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a flow chart of a preferred embodiment of a communication optimization method based on Unix sockets of the present invention;

[0040] Figure 2 It is a schematic diagram of the principle of a preferred embodiment of a communication optimization system based on Unix sockets of the present invention;

[0041] Figure 3Schematic diagram of the operating environment of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0043] A communication optimization method based on Unix sockets described in a preferred embodiment of the present invention is as follows: Figure 1 As shown, the communication optimization method based on Unix socket comprises the following steps:

[0044] Step S10: define a selection variable in the communication configuration file, and modify the macro definition according to the selection variable to obtain a macro definition configuration.

[0045] Specifically, a communication configuration file is a file used to store various configuration parameters and options, usually in plain text format, containing some key-value pairs, which are used to specify various parameters and settings of the communication system. The main function of the configuration file is to enable the configuration to be managed and modified independently of the code, thereby simplifying the debugging and optimization process. Selection variables are defined in the configuration file to control different communication parameters. Macro definition is a preprocessing instruction used to define constants or simplify code in programming. According to the selection variables defined in the communication configuration file, the program will modify these macro definitions, and the modified macro definitions will form a new macro definition configuration, which will take effect at compile time or runtime, thereby avoiding a large number of modifications to the source code.

[0046] Further, the step of defining a selection variable in the communication configuration file and modifying the macro definition according to the selection variable to obtain the macro definition configuration specifically includes:

[0047] A selection variable of a Unix socket communication mode and a value of the selection variable are defined in a communication configuration file, and different communication modes are selected according to the value of the selection variable.

[0048] In the compiled file, the macro definition is dynamically modified during the compilation process according to the value of the variable to obtain the macro definition configuration.

[0049] Specifically, open or create a communication configuration file (such as wpa.gni), and define a selection variable in the communication configuration file to identify the communication method used by the system (such as Unix socket or UDP). The selection variable and its value will be used to control the generation of different macro definitions during the compilation process, so as to dynamically adjust the communication mode of the system. For example, the name of the selection variable CONFIG_CTRL_IFACE is defined in the communication configuration file, and the value of the variable is defined at the same time, which can be "unix" or "udp", indicating the use of UDP communication mode or Unix socket communication mode respectively. According to the value of the selection variable CONFIG_CTRL_IFACE, macro definitions are selectively added or deleted. When the value of the selection variable is "unix", the macro definition WPA_CTRL_IFACE_UNIX is added, and the original macro definition WPA_CTRL_IFACE_UDP is removed to obtain a new macro definition configuration. At the same time, in order to ensure the successful compilation of Unix socket communication, the definition of the original control communication interface function "wpa_ctrl_port" between the client and the server is moved to CONFIG_CTRL_IFACE_UDP. By dynamically modifying the macro definition and adding selection logic, the code can be conditionally compiled according to different communication modes.

[0050] Furthermore, it is necessary to create udp_socket and unix_socket subfolders to store configuration files for different communication methods, modify the corresponding startup commands, find the directory path of CONFIG_CTRL_IFACE_CLIENT_DIR in the macro definition configuration in the relevant source files, and change its directory path from / tmp to / data / service / el1 / public / wifi, which solves the problem of wifi users' access rights to the / tmp directory and ensures the correctness of the client control interface path.

[0051] Step S20, modifying the communication control file to obtain a target communication control file, and adjusting the control interface paths of the client and the server according to the target communication control file and the macro definition configuration.

[0052] Specifically, in a network communication system, the communication interface paths of the client and server are usually predefined, and these paths are used to identify the communication endpoints between different processes. In traditional communication methods, such as when using the UDP protocol, the communication interface path may be set in a temporary directory (such as / tmp). However, in order to improve the security and efficiency of the system, the communication method can be switched to a Unix socket-based method, and the interface path definition in the communication control file can be adjusted accordingly.

[0053] Further, the communication control file is modified to obtain a target communication control file, and the control interface paths of the client and the server are adjusted according to the target communication control file and the macro definition configuration, specifically including:

[0054] Add the definition of the Unix socket path in the communication control file to obtain the target communication control file.

[0055] The control interface paths of the client and server are modified to the Unix socket paths according to the target communication control file and the macro definition configuration.

[0056] The control interface path is verified and access permissions are configured.

[0057] Specifically, in the existing communication control file, new definitions are added to support Unix socket paths to ensure that Unix sockets can be recognized and used for communication. As an example, the wpa.gni file is imported, and the communication interface path defined in the communication control file is UDP and the control interface path. Therefore, the definition of the Unix socket path is added to the communication control file, the communication mode is changed to Unix socket, and the communication control interface path is modified accordingly to ensure that the new Unix communication path definition meets the system's security and storage location requirements.

[0058] By using macro definition configuration, the control interface path can also be dynamically adjusted to support Unix sockets. After completing the path definition and code modification, the control interface path needs to be verified and appropriate access permissions need to be configured to ensure the reliability and security of communication. For example, during the system deployment process, the existence (whether the control interface path exists) and accessibility (whether the control interface path has appropriate read and write permissions) of the control interface path can be verified by executing a script. The control interface path can be verified by executing the following command in the shell:

[0059] -e" / data / service / el1 / public / wifi / sockets / wpa does it exist?

[0060] -r " / data / service / el1 / public / wifi / sockets / wpa" # Check read permissions.

[0061] -w" / data / service / el1 / public / wifi / sockets / wpa"#Check write permissions.

[0062] After ensuring the correct read and write permissions, further configure access permissions to ensure that the client and server can correctly access the control interface path. For example, you can use:

[0063] #Configure path read, write and execute permissions

[0064] chmod 755 / data / service / el1 / public / wifi / sockets / wpa

[0065] #Configure the path owner and group

[0066] chown wifi_user:wifi_group data / service / el1 / public / wifi / sockets / wpa

[0067] The script sets the path permissions to 755, which allows all users to read and execute, and the owner to write. It then sets the path owner and group to wifi_user and wifi_group, ensuring that only specific users and groups can access the path. This effectively verifies and configures permissions on the control interface path, ensuring that the client and server can communicate securely and reliably based on Unix sockets.

[0068] Step S30: generating an initialization configuration according to the target communication control file, and adjusting a preset startup script according to the initialization configuration to obtain a startup configuration.

[0069] Specifically, the initialization configuration refers to a series of parameters and settings required before the client and server are started. The process of generating the initialization configuration needs to be carried out according to the content defined in the target communication control file, and the preset startup script needs to be adjusted, including modifying the startup command and script according to the initialization configuration, and setting execution permissions, etc., to ensure that the startup process can be executed correctly.

[0070] Further, generating an initialization configuration according to the target communication control file specifically includes:

[0071] According to the target communication control file, an initialization function is defined in the client and the server.

[0072] An initialization process is selected according to the initialization function and initialization parameters are set, and the initialization process and the initialization parameters are combined to generate an initialization configuration.

[0073] Specifically, firstly, initialization functions are defined in the client and server, respectively, to perform necessary initialization operations, and the initialization functions are configured according to the contents in the target communication control file. The target communication control file is read and parsed, necessary initialization parameters are extracted, and corresponding initialization functions are defined in the client and server codes. After the initialization function is defined, an appropriate initialization process is selected and initialization parameters are set according to the function, ensuring that the initialization process of the client and server meets the requirements of the target communication control file, and the selected initialization process and initialization parameters are combined to form an initialization configuration.

[0074] Further, adjusting the preset startup script according to the initialization configuration to obtain the startup configuration specifically includes:

[0075] A startup instruction is constructed according to the initialization parameters.

[0076] The preset startup script is modified, the startup instruction is written into the preset startup script, and the execution permission of the startup script is set to obtain the startup configuration.

[0077] Specifically, by constructing startup instructions according to initialization parameters, modifying the preset startup script, and setting the execution permissions of the script, it is ensured that the client and server can start correctly and communicate effectively. Constructing startup instructions is to generate specific instructions for starting the client and server according to the initialization parameters. The initialization parameters include the control interface path, the configuration file path, etc., which can be extracted from the initialization configuration. According to the extracted initialization parameters, the instructions for starting the client and server are generated, and the preset startup script is modified. The generated startup instructions are written into the script file so that these instructions can be executed when the system starts. In order to ensure that the startup script can be executed, it is necessary to set the execution permissions of the script file. As an example, the execution permissions of the startup script can be set using the system system command, and chmod+x can be used to add execution permissions to the file. Finally, the correct startup configuration is obtained to achieve effective startup and communication between the client and server.

[0078] Step S40: According to the startup configuration, control the client and the server to perform Unix socket communication.

[0079] Specifically, after generating the startup configuration, the client and server need to be started according to the configuration. The specific implementation method may include starting the client and server, initializing the Unix socket path, and performing communication tests. For example, the client needs to communicate with the server (such as hostapd). In this case, the client connection command needs to be dynamically adjusted according to different communication modes (UDP or Unix socket), and the command for the client to connect to hostapd needs to be modified. A new function GetCtrlInterface is added, wherein the function GetCtrlInterface is used to select a suitable control interface path according to the current macro definition (such as "WPA_CTRL_IFACE_UNIX"). If Unix socket is used, the path of Unix socket is returned; if UDP is used, the port information of UDP is returned, thereby selecting to call different interfaces according to the macro definition.

[0080] Furthermore, in Unix socket communication, SELinux (Security-Enhanced Linux) is a mandatory access control system used to enhance the security of Linux systems. In order to ensure that the WiFi module can correctly use the Unix socket for communication, it is also necessary to configure appropriate SELinux permissions for it. For example, a type can be defined for the WiFi module, and processes of this type can be allowed to access the Unix socket path and access the specified directory. By increasing the SELinux permissions of the WiFi module, it can be ensured that in a strict security environment, the WiFi module can normally access and use the Unix socket for communication.

[0081] Furthermore, the client and server are started according to the startup configuration, so that the two processes are in a communicative state. The execution of the startup script ensures that the client and server are loaded and ready to communicate. After starting the client and server, the Unix socket path between them is initialized, and finally test messages are sent and received to ensure that the client and server can communicate normally.

[0082] Further, the step of controlling the client and the server to perform Unix socket communication according to the startup configuration further includes:

[0083] The macro definition configuration is verified by analyzing the communication configuration file.

[0084] The initialization configuration is verified by analyzing the initialization logs of the client and the server.

[0085] Run the startup test script to verify the startup configuration.

[0086] Specifically, ensuring the correctness and validity of the configuration is a key step to ensure the stable operation of the system and the reliability of communication. Therefore, before executing communication, the macro definition configuration, initialization configuration and startup configuration need to be fully verified.

[0087] First, read the contents of the communication configuration file and check whether the variable definitions and macro definitions are as expected. In the communication configuration file, check whether the definition of the "CONFIG_CTRL_IFACE" variable is correct and make sure its value is set to the Unix socket.

[0088] Furthermore, open the initialization log files of the client and server, read the content line by line, check whether the log contains "initialization success" or similar information, and confirm whether the initialization parameters and process are executed correctly. If the initialization success information is not found, it is necessary to check the initialization steps to find and solve the existing problems. That is, in the client initialization log, find the initialization success information to ensure that all initialization steps are completed as expected.

[0089] Further, a preset startup test script is executed to check whether the client and server are correctly started and communicate. The startup test script contains a series of commands and scripts to ensure that the client and server can correctly start and initialize Unix socket communication. Finally, the communication status of the client and server is confirmed through the communication test message, and the test result log is checked to ensure that all communication test messages can be correctly sent and received. Thus, through the above verification steps, the correctness and effectiveness of the macro definition configuration, initialization configuration and startup configuration can be ensured, providing guarantee for the smooth progress of Unix socket communication.

[0090] Furthermore, if Figure 2 As shown, based on the above-mentioned communication optimization method based on Unix socket, the present invention also provides a communication optimization system based on Unix socket, wherein the communication optimization system based on Unix socket includes:

[0091] A macro definition module 51, used to define selection variables in a communication configuration file, and to modify the macro definition according to the selection variables to obtain a macro definition configuration;

[0092] The communication control module 52 is used to modify the communication control file to obtain a target communication control file, and adjust the control interface paths of the client and the server according to the target communication control file and the macro definition configuration;

[0093] An initialization module 53, used to generate an initialization configuration according to the target communication control file, and adjust a preset startup script according to the initialization configuration to obtain a startup configuration;

[0094] The communication module 54 is used to control the client and the server to perform Unix socket communication according to the startup configuration.

[0095] Furthermore, if Figure 3 As shown, based on the above-mentioned communication optimization method and system based on Unix socket, the present invention also provides a terminal accordingly, and the terminal includes a processor 10, a memory 20 and a display 30. Figure 3 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0096] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed on the terminal, such as the program code of the installation terminal, etc. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a communication optimization program 40 based on a Unix socket is stored on the memory 20, and the communication optimization program 40 based on a Unix socket can be executed by the processor 10, thereby realizing the communication optimization method based on a Unix socket in the present application.

[0097] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the communication optimization method based on Unix sockets.

[0098] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a system bus.

[0099] In one embodiment, when the processor 10 executes a Unix socket-based communication optimization program 40 in the memory 20, the following steps are implemented:

[0100] Defining a selection variable in a communication configuration file, and modifying a macro definition according to the selection variable to obtain a macro definition configuration;

[0101] Modify the communication control file to obtain a target communication control file, and adjust the control interface paths of the client and the server according to the target communication control file and the macro definition configuration;

[0102] Generate an initialization configuration according to the target communication control file, and adjust a preset startup script according to the initialization configuration to obtain a startup configuration;

[0103] According to the startup configuration, the client and the server are controlled to perform Unix socket communication.

[0104] The step of defining a selection variable in a communication configuration file and modifying a macro definition according to the selection variable to obtain a macro definition configuration specifically includes:

[0105] Defining a selection variable of a Unix socket communication mode and a value of the selection variable in a communication configuration file, and selecting a different communication mode according to the value of the selection variable;

[0106] In the compiled file, the macro definition is dynamically modified during the compilation process according to the value of the variable to obtain the macro definition configuration.

[0107] The modifying of the communication control file to obtain a target communication control file and adjusting the control interface paths of the client and the server according to the target communication control file and the macro definition configuration specifically include:

[0108] Add the definition of Unix socket path in the communication control file to get the target communication control file;

[0109] Modifying the control interface paths of the client and the server to the Unix socket paths according to the target communication control file and the macro definition configuration;

[0110] The control interface path is verified and access permissions are configured.

[0111] The generating of the initialization configuration according to the target communication control file specifically includes:

[0112] According to the target communication control file, defining initialization functions in the client and the server;

[0113] An initialization process is selected according to the initialization function and initialization parameters are set, and the initialization process and the initialization parameters are combined to generate an initialization configuration.

[0114] The step of adjusting the preset startup script according to the initialization configuration to obtain the startup configuration specifically includes:

[0115] Constructing a startup instruction according to the initialization parameters;

[0116] The preset startup script is modified, the startup instruction is written into the preset startup script, and the execution permission of the startup script is set to obtain the startup configuration.

[0117] Wherein, controlling the client and the server to perform Unix socket communication according to the startup configuration specifically includes:

[0118] Starting the client and the server according to the startup configuration, and initializing the Unix socket path between the client and the server;

[0119] A communication test is performed on the client and the server, and if the test passes, Unix socket communication between the client and the server is established.

[0120] Wherein, according to the startup configuration, controlling the client and the server to perform Unix socket communication also includes:

[0121] Verifying the macro definition configuration by analyzing the communication configuration file;

[0122] Verifying the initialization configuration by analyzing the initialization logs of the client and the server;

[0123] Run the startup test script to verify the startup configuration.

[0124] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a communication optimization program based on a Unix socket, and when the communication optimization program based on a Unix socket is executed by a processor, the steps of the communication optimization method based on a Unix socket as described above are implemented.

[0125] In summary, the present invention provides a communication optimization method, system, terminal and computer-readable storage medium based on Unix sockets, the method comprising: defining a selection variable in a communication configuration file, modifying a macro definition according to the selection variable, and obtaining a macro definition configuration; modifying a communication control file to obtain a target communication control file, and adjusting the control interface paths of a client and a server according to the target communication control file and the macro definition configuration; generating an initialization configuration according to the target communication control file, adjusting a preset startup script according to the initialization configuration, and obtaining a startup configuration; and controlling the client and the server to perform Unix socket communication according to the startup configuration. The present invention realizes efficient communication between WiFi HAL and WPA by providing a standard local communication interface, simplifies the system architecture, and improves communication performance and system stability.

[0126] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or terminal including the element.

[0127] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium that can be read by a computer, and the program can include the processes of the above-mentioned method embodiments when executed. The computer-readable storage medium can be a memory, a disk, an optical disk, etc.

[0128] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.

Claims

1. A communication optimization method based on Unix socket, characterized in that: The communication optimization method based on Unix sockets comprises: Defining a selection variable in a communication configuration file, and modifying a macro definition according to the selection variable to obtain a macro definition configuration; Modify the communication control file to obtain a target communication control file, and adjust the control interface paths of the client and the server according to the target communication control file and the macro definition configuration; Generate an initialization configuration according to the target communication control file, and adjust a preset startup script according to the initialization configuration to obtain a startup configuration; According to the startup configuration, the client and the server are controlled to perform Unix socket communication.

2. The communication optimization method based on Unix socket according to claim 1, characterized in that: The step of defining a selection variable in a communication configuration file and modifying a macro definition according to the selection variable to obtain a macro definition configuration specifically includes: Defining a selection variable of a Unix socket communication mode and a value of the selection variable in a communication configuration file, and selecting a different communication mode according to the value of the selection variable; In the compiled file, the macro definition is dynamically modified during the compilation process according to the value of the variable to obtain the macro definition configuration.

3. The communication optimization method based on Unix socket according to claim 1, characterized in that: The modifying of the communication control file to obtain a target communication control file, and adjusting the control interface paths of the client and the server according to the target communication control file and the macro definition configuration, specifically includes: Add the definition of Unix socket path in the communication control file to get the target communication control file; Modifying the control interface paths of the client and the server to the Unix socket paths according to the target communication control file and the macro definition configuration; The control interface path is verified and access permissions are configured.

4. The communication optimization method based on Unix socket according to claim 1, characterized in that: Generating the initialization configuration according to the target communication control file specifically includes: According to the target communication control file, defining initialization functions in the client and the server; An initialization process is selected according to the initialization function and initialization parameters are set, and the initialization process and the initialization parameters are combined to generate an initialization configuration.

5. The communication optimization method based on Unix socket according to claim 4, characterized in that: The step of adjusting the preset startup script according to the initialization configuration to obtain the startup configuration specifically includes: Constructing a startup instruction according to the initialization parameters; The preset startup script is modified, the startup instruction is written into the preset startup script, and the execution permission of the startup script is set to obtain the startup configuration.

6. The communication optimization method based on Unix socket according to claim 3, characterized in that: According to the startup configuration, controlling the client and the server to perform Unix socket communication specifically includes: Starting the client and the server according to the startup configuration, and initializing the Unix socket path between the client and the server; A communication test is performed on the client and the server, and if the test passes, Unix socket communication between the client and the server is established.

7. The communication optimization method based on Unix socket according to claim 1, characterized in that: According to the startup configuration, controlling the client and the server to perform Unix socket communication also includes: Verifying the macro definition configuration by analyzing the communication configuration file; Verifying the initialization configuration by analyzing the initialization logs of the client and the server; Run the startup test script to verify the startup configuration.

8. A communication optimization system based on Unix sockets, characterized in that: The communication optimization system based on Unix sockets comprises: A macro definition module, used for defining selection variables in a communication configuration file, and modifying the macro definition according to the selection variables to obtain a macro definition configuration; A communication control module, used for modifying a communication control file to obtain a target communication control file, and adjusting the control interface paths of the client and the server according to the target communication control file and the macro definition configuration; An initialization module, used to generate an initialization configuration according to the target communication control file, and adjust a preset startup script according to the initialization configuration to obtain a startup configuration; The communication module is used to control the client and the server to perform Unix socket communication according to the startup configuration.

9. A terminal, characterized in that: The terminal includes: a memory, a processor, and a Unix socket-based communication optimization program stored in the memory and executable on the processor. When the Unix socket-based communication optimization program is executed by the processor, the steps of the Unix socket-based communication optimization method as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a communication optimization program based on a Unix socket, and when the communication optimization program based on a Unix socket is executed by a processor, the steps of the communication optimization method based on a Unix socket are implemented as described in any one of claims 1 to 7.