32 lines
737 B
C++
32 lines
737 B
C++
// UnixIpcBridge.hpp
|
||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||
// 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();
|
||
};
|