25 #ifndef CARGO_IPC_INTERNALS_SOCKET_HPP
26 #define CARGO_IPC_INTERNALS_SOCKET_HPP
43 typedef std::unique_lock<std::recursive_mutex>
Guard;
51 explicit Socket(
int socketFD = -1);
70 void write(const
void* bufferPtr, const
size_t size) const;
78 void read(
void* bufferPtr, const
size_t size) const;
119 #endif // CARGO_IPC_INTERNALS_SOCKET_HPP
This class wraps all operations possible to do with a socket.
Definition: socket.hpp:40
int mFD
Definition: socket.hpp:109
void write(const void *bufferPtr, const size_t size) const
Write data using the file descriptor.
Definition: socket.cpp:154
std::shared_ptr< Socket > accept()
Accepts connection.
Definition: socket.cpp:142
static int getSystemdSocketInternal(const std::string &path)
static Socket createSocket(const std::string &path)
Prepares socket for accepting connections.
Definition: socket.cpp:233
int getFD() const
Definition: socket.cpp:137
static int createSocketInternal(const std::string &path)
Definition: socket.cpp:189
std::recursive_mutex mCommunicationMutex
Definition: socket.hpp:110
static Socket connectSocket(const std::string &path, const int timeoutMs=1000)
Connects to a socket.
Definition: socket.cpp:249
Socket::Guard getGuard() const
Definition: socket.cpp:132
Socket(int socketFD=-1)
Default constructor.
Definition: socket.cpp:112
std::unique_lock< std::recursive_mutex > Guard
Definition: socket.hpp:43
void read(void *bufferPtr, const size_t size) const
Reads a value of the given type.
Definition: socket.cpp:160