feat: implemented unix domain socket helper header and tests

This commit is contained in:
2026-03-10 17:47:09 +00:00
parent e1360ccbb4
commit f63d40cffb
2 changed files with 251 additions and 0 deletions

31
include/UnixIpcBridge.hpp Normal file
View File

@@ -0,0 +1,31 @@
// UnixIpcBridge.hpp
// SPDX-License-Identifier: GPL-3.0-only
// Author: Unai Blazquez <unaibg2000@gmail.com>
#pragma once
#include <fcntl.h> // nonblocking
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h> // close()
#include <string>
///@brief Small bridge to allow the producer class to send data over UNIX domain
/// sockets
class UnixIpcBridge
{
public:
///@brief constructor
///@param socket path pointing the socket
explicit UnixIpcBridge(const std::string& socket_path);
///@brief sending function, this goes into the producer
///@param integer to send over the socket
void send(int value);
private:
std::string m_socket_path;
int m_socket_fd = -1;
void connect_to_consumer();
};