Class UnixDomainSocket
Defined in File unix_domain_socket.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public DesignPattern::Creation< UnixDomainSocket, IpcChannelError >(Template Class Creation)
Class Documentation
-
class UnixDomainSocket : public DesignPattern::Creation<UnixDomainSocket, IpcChannelError>
Wrapper class for unix domain socket.
Public Types
-
using UdsName_t = cxx::string<LONGEST_VALID_NAME>
-
using Message_t = cxx::string<MAX_MESSAGE_SIZE>
Public Functions
-
UnixDomainSocket() noexcept
default constructor. The result is an invalid UnixDomainSocket object which can be reassigned later by using the move constructor.
-
UnixDomainSocket(const UnixDomainSocket &other) = delete
-
UnixDomainSocket(UnixDomainSocket &&other) noexcept
-
UnixDomainSocket &operator=(const UnixDomainSocket &other) = delete
-
UnixDomainSocket &operator=(UnixDomainSocket &&other) noexcept
-
~UnixDomainSocket() noexcept
-
cxx::expected<IpcChannelError> destroy() noexcept
close the unix domain socket.
-
cxx::expected<IpcChannelError> send(const std::string &msg) const noexcept
send a message using std::string.
- Parameters:
msg – to send
- Returns:
IpcChannelError if error occured
-
cxx::expected<IpcChannelError> timedSend(const std::string &msg, const units::Duration &timeout) const noexcept
try to send a message for a given timeout duration using std::string
- Parameters:
msg – to send
timout – for the send operation
- Returns:
IpcChannelError if error occured
-
cxx::expected<std::string, IpcChannelError> receive() const noexcept
receive message using std::string.
- Returns:
received message. In case of an error, IpcChannelError is returned and msg is empty.
-
cxx::expected<std::string, IpcChannelError> timedReceive(const units::Duration &timeout) const noexcept
try to receive message for a given timeout duration using std::string.
- Parameters:
timout – for the receive operation
- Returns:
received message. In case of an error, IpcChannelError is returned and msg is empty.
-
cxx::expected<bool, IpcChannelError> isOutdated() noexcept
checks whether the unix domain socket is outdated
- Returns:
true if the unix domain socket is outdated, false otherwise, IpcChannelError if error occured
Public Static Functions
-
static cxx::expected<bool, IpcChannelError> unlinkIfExists(const UdsName_t &name) noexcept
unlink the provided unix domain socket
- Parameters:
name – of the unix domain socket to unlink
- Returns:
true if the unix domain socket could be unlinked, false otherwise, IpcChannelError if error occured
-
static cxx::expected<bool, IpcChannelError> unlinkIfExists(const NoPathPrefix_t, const UdsName_t &name) noexcept
unlink the provided unix domain socket
- Parameters:
NoPathPrefix – signalling that this method does not add a path prefix
name – of the unix domain socket to unlink
- Returns:
true if the unix domain socket could be unlinked, false otherwise, IpcChannelError if error occured
Public Static Attributes
-
static constexpr NoPathPrefix_t NoPathPrefix = {}
-
static constexpr uint64_t NULL_TERMINATOR_SIZE = 1U
-
static constexpr uint64_t MAX_MESSAGE_SIZE = platform::IOX_UDS_SOCKET_MAX_MESSAGE_SIZE - NULL_TERMINATOR_SIZE
-
static constexpr size_t LONGEST_VALID_NAME = sizeof(sockaddr_un::sun_path) - 1
The name length is limited by the size of the sockaddr_un::sun_path buffer and the IOX_SOCKET_PATH_PREFIX.
Friends
- friend class DesignPattern::Creation< UnixDomainSocket, IpcChannelError >
-
struct NoPathPrefix_t
-
using UdsName_t = cxx::string<LONGEST_VALID_NAME>