Linux开发:进程间通过Unix Domain Socket传递数据-CSDN博客
介绍了通过UDS传递数据
实际上当需要传递大量的数据时,可以通过UDS直接传递文件描述符,这样接收文件描述符的一方,可以直接从传递过来的文件描述符读取数据
先举例说明:
//uds_fd.hpp
#pragma once
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <string>
#include <iostream>
#include <filesystem>using namespace std;
namespace fs = std::filesystem;class UDSFd{
public:UDSFd(){//创建基于数据包的通信,类似UDPm_sockFd = socket(AF_UNIX, SOCK_DGRAM, 0);if(m_sockFd == -1){cout << "create socket failed" <<endl;}}int bindFile(const string& sockFilePath){if(m_sock