feat: implemented unix domain socket helper header and tests
This commit is contained in:
31
include/UnixIpcBridge.hpp
Normal file
31
include/UnixIpcBridge.hpp
Normal 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> // non‑blocking
|
||||
#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();
|
||||
};
|
||||
Reference in New Issue
Block a user