# socket_ipc **Repository Path**: chasentech/socket_ipc ## Basic Information - **Project Name**: socket_ipc - **Description**: socket_ipc - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-07-27 - **Last Updated**: 2024-08-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # socket-ipc ![language](https://img.shields.io/badge/Language-c++-brightgreen.svg) platform: ubuntu # How to build 1. download 2. make, `sh build.sh` # How to run ## log config 1. Setting the log through environment variables ```bash # set log level export TLOG_LEVEL=error/warn/info/debug/verbose # set log to file export TLOG_FILE=nofile/file_name # delete TLOG_LEVEL environment variable, default is info unset TLOG_LEVEL # delete TLOG_FILE environment variable, default is disable unset TLOG_FILE ``` ## server ```bash # exec this cmd in terminal ./output/socket_ipc/bin/ser ``` ## client ```bash # exec this cmd in another terminal ./output/socket_ipc/bin/cli -n ui & ./output/socket_ipc/bin/cli -n ui -I ``` # description ## 服务端设计 1. 服务端维护一个全局表,包括IP、port、sockfd、to_fd、name ```c++ typedef struct CliInfo { char IP[INET_ADDRSTRLEN]; //INET_ADDRSTRLEN = 16 int port; int sockfd; int to_fd; char name[20]; } CliInfo; ``` ## 客户端设计 1. 客户端执行的时候,第一条命令`cli -n ui &`,会在本地创建一个`/tmp/fifo_cli + _name`的fifo,在后台运行 第二个命令`cli -n ui -I`会进入`input_loop`,和创建的fifo进行通讯,两次的name必须一样 # FAQ