Wrapper class for unix domain socket.
More...
#include <unix_domain_socket.hpp>
|
|
using | UdsName_t = cxx::string< LONGEST_VALID_NAME > |
| |
|
using | CreationPattern_t = Creation< UnixDomainSocket, IpcChannelError > |
| |
|
using | result_t = iox::cxx::expected< UnixDomainSocket, IpcChannelError > |
| |
|
using | errorType_t = IpcChannelError |
| |
|
|
| 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 |
| |
|
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. More...
|
| |
| 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 More...
|
| |
| cxx::expected< std::string, IpcChannelError > | receive () const noexcept |
| | receive message using std::string. More...
|
| |
| cxx::expected< std::string, IpcChannelError > | timedReceive (const units::Duration &timeout) const noexcept |
| | try to receive message for a given timeout duration using std::string. More...
|
| |
| cxx::expected< bool, IpcChannelError > | isOutdated () noexcept |
| | checks whether the unix domain socket is outdated More...
|
| |
|
| Creation (Creation &&rhs) noexcept |
| |
|
| Creation (const Creation &rhs) noexcept=default |
| |
|
Creation & | operator= (Creation &&rhs) noexcept |
| |
|
Creation & | operator= (const Creation &rhs) noexcept=default |
| |
|
bool | isInitialized () const noexcept |
| | returns true if the object was constructed successfully, otherwise false
|
| |
|
| static cxx::expected< bool, IpcChannelError > | unlinkIfExists (const UdsName_t &name) noexcept |
| | unlink the provided unix domain socket More...
|
| |
| static cxx::expected< bool, IpcChannelError > | unlinkIfExists (const NoPathPrefix_t, const UdsName_t &name) noexcept |
| | unlink the provided unix domain socket More...
|
| |
| static result_t | create (Targs &&... args) noexcept |
| | factory method which guarantees that either a working object is produced or an error value describing the error during construction More...
|
| |
| static result_t | verify (UnixDomainSocket &&newObject) noexcept |
| | verifies if a class was created successfully More...
|
| |
| static iox::cxx::expected< IpcChannelError > | placementCreate (void *const memory, Targs &&... args) noexcept |
| | factory method which guarantees that either a working object is produced or an error value describing the error during construction More...
|
| |
|
|
static constexpr NoPathPrefix_t | NoPathPrefix {} |
| |
|
static constexpr char | PATH_PREFIX [] = "/tmp/" |
| |
|
static constexpr size_t | MAX_MESSAGE_SIZE = 2048U |
| | Max message size is on linux = 4096 and on mac os = 2048. To have the same behavior on every platform we use 2048.
|
| |
|
static constexpr size_t | SHORTEST_VALID_NAME = 2U |
| |
|
static constexpr size_t | NULL_TERMINATOR_SIZE = 1 |
| |
|
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 path prefix.
|
| |
|
static constexpr int32_t | ERROR_CODE = -1 |
| |
|
static constexpr int32_t | INVALID_FD = -1 |
| |
|
|
bool | m_isInitialized |
| |
|
IpcChannelError | m_errorValue |
| |
Wrapper class for unix domain socket.
◆ isOutdated()
| cxx::expected<bool, IpcChannelError> iox::posix::UnixDomainSocket::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
◆ receive()
| cxx::expected<std::string, IpcChannelError> iox::posix::UnixDomainSocket::receive |
( |
| ) |
const |
|
noexcept |
receive message using std::string.
- Returns
- received message. In case of an error, IpcChannelError is returned and msg is empty.
◆ send()
| cxx::expected<IpcChannelError> iox::posix::UnixDomainSocket::send |
( |
const std::string & |
msg | ) |
const |
|
noexcept |
send a message using std::string.
- Parameters
-
- Returns
- IpcChannelError if error occured
◆ timedReceive()
| cxx::expected<std::string, IpcChannelError> iox::posix::UnixDomainSocket::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.
◆ timedSend()
| cxx::expected<IpcChannelError> iox::posix::UnixDomainSocket::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
◆ unlinkIfExists() [1/2]
| static cxx::expected<bool, IpcChannelError> iox::posix::UnixDomainSocket::unlinkIfExists |
( |
const |
NoPathPrefix_t, |
|
|
const UdsName_t & |
name |
|
) |
| |
|
staticnoexcept |
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
◆ unlinkIfExists() [2/2]
| static cxx::expected<bool, IpcChannelError> iox::posix::UnixDomainSocket::unlinkIfExists |
( |
const UdsName_t & |
name | ) |
|
|
staticnoexcept |
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
The documentation for this class was generated from the following file: