uvw 3.4.0
Loading...
Searching...
No Matches
pipe.h
1#ifndef UVW_PIPE_INCLUDE_H
2#define UVW_PIPE_INCLUDE_H
3
4#include <memory>
5#include <string>
6#include <type_traits>
7#include <uv.h>
8#include "config.h"
9#include "enum.hpp"
10#include "loop.h"
11#include "request.hpp"
12#include "stream.h"
13#include "util.h"
14
15namespace uvw {
16
17namespace details {
18
19enum class uvw_chmod_flags : std::underlying_type_t<uv_poll_event> {
20 READABLE = UV_READABLE,
21 WRITABLE = UV_WRITABLE,
22 _UVW_ENUM = 0
23};
24
25}
26
38class pipe_handle final: public stream_handle<pipe_handle, uv_pipe_t> {
39public:
40 using chmod_flags = details::uvw_chmod_flags;
41
42 explicit pipe_handle(loop::token token, std::shared_ptr<loop> ref, bool pass = false);
43
48 int init();
49
59 int open(file_handle file);
60
70 int bind(const std::string &name, const bool no_truncate = false);
71
83 int connect(const std::string &name, const bool no_truncate = false);
84
90 std::string sock() const noexcept;
91
98 std::string peer() const noexcept;
99
109 void pending(int count) noexcept;
110
115 int pending() noexcept;
116
134
152 int chmod(chmod_flags flags) noexcept;
153
154private:
155 bool ipc;
156};
157
158} // namespace uvw
159
160#ifndef UVW_AS_LIB
161# include "pipe.cpp"
162#endif
163
164#endif // UVW_PIPE_INCLUDE_H
int open(file_handle file)
Opens an existing file descriptor or HANDLE as a pipe.
int init()
Initializes the handle.
handle_type receive() noexcept
Used to receive handles over IPC pipes.
std::string peer() const noexcept
Gets the name of the Unix domain socket or the named pipe to which the handle is connected.
int connect(const std::string &name, const bool no_truncate=false)
Connects to the Unix domain socket or the named pipe.
std::string sock() const noexcept
Gets the name of the Unix domain socket or the named pipe.
int bind(const std::string &name, const bool no_truncate=false)
bind Binds the pipe to a file path (Unix) or a name (Windows).
void pending(int count) noexcept
Sets the number of pending pipe this instance can handle.
int chmod(chmod_flags flags) noexcept
Alters pipe permissions.
The stream handle.
Definition stream.h:108
uvw default namespace.
Definition async.h:8
details::uvw_handle_type handle_type
Definition util.h:83
details::uv_type_wrapper< uv_file > file_handle
Definition util.h:85