xentara-utils v2.0.4
The Xentara Utility Library
|
A class to create a named pipe server. More...
#include <xentara/utils/ipc/NamedPipeServer.hpp>
Public Types | |
enum class | Scope { User , Global } |
Scopes for names pipe servers. More... | |
Public Member Functions | |
NamedPipeServer ()=default | |
Default constructor. | |
NamedPipeServer (std::reference_wrapper< const io::StopSource > stopSource) noexcept | |
Constructor that associates a stop source with the named pipe server. | |
NamedPipeServer (std::string_view name, Scope scope) | |
Constructor that listens for client connections. | |
NamedPipeServer (std::string_view name, Scope scope, std::reference_wrapper< const io::StopSource > stopSource) | |
Constructor that listens for client connections using a stop source. | |
auto | setStopSource (const io::StopSource &stopSource) noexcept -> void |
Associates a stop source with the named pipe. | |
auto | removeStopSource () noexcept -> void |
Removes any associated stop source from the named pipe. | |
auto | listen (std::string_view name, Scope scope) -> void |
Listens for client connections. | |
auto | accept () -> NamedPipe |
Accepts a client connection. | |
auto | accept (std::optional< std::chrono::nanoseconds > timeout) -> NamedPipe |
Accepts a client connection. | |
auto | close () -> void |
Closes the connection of socket/handler. | |
A class to create a named pipe server.
|
strong |
|
default |
Default constructor.
|
explicitnoexcept |
Constructor that associates a stop source with the named pipe server.
xentara::utils::ipc::NamedPipeServer::NamedPipeServer | ( | std::string_view | name, |
Scope | scope | ||
) |
Constructor that listens for client connections.
name | The name to listen to |
scope | The scope |
std::runtime_error | An error occurred listening to the pipe name |
xentara::utils::ipc::NamedPipeServer::NamedPipeServer | ( | std::string_view | name, |
Scope | scope, | ||
std::reference_wrapper< const io::StopSource > | stopSource | ||
) |
Constructor that listens for client connections using a stop source.
name | The name to listen to |
scope | The scope |
stopSource | The stop source to associates with the named pipe server |
std::runtime_error | An error occurred listening to the pipe name |
auto xentara::utils::ipc::NamedPipeServer::accept | ( | ) | -> NamedPipe |
Accepts a client connection.
io::StopRequested | The stop source associated with the named pipe server was triggered. |
std::runtime_error | An error occurred accepting the connection |
auto xentara::utils::ipc::NamedPipeServer::accept | ( | std::optional< std::chrono::nanoseconds > | timeout | ) | -> NamedPipe |
Accepts a client connection.
timeout | The timeout, or std::nullopt to use an infinite timeout. |
The accepted socket, or a default constructed named pipe on timeout. You can use the [operator bool()]NamedPipe::operator bool()) to check whether the returned named pipe is valid.
If the named pipe server has a stop source associated with it, the returned object will use the same stop source.
io::StopRequested | The stop source associated with the named pipe server was triggered. |
std::runtime_error | An error occurred accepting the connection |
auto xentara::utils::ipc::NamedPipeServer::close | ( | ) | -> void |
Closes the connection of socket/handler.
auto xentara::utils::ipc::NamedPipeServer::listen | ( | std::string_view | name, |
Scope | scope | ||
) | -> void |
Listens for client connections.
name | The name to listen to |
scope | The scope |
std::runtime_error | An error occurred |
|
noexcept |
Removes any associated stop source from the named pipe.
|
noexcept |
Associates a stop source with the named pipe.
If you set a stop source, accept() will throw an exception of type io::StopRequested if a stop is requested on the stop source.
stopSource | The stop source to associates with the named pipe server |