uvw 3.1.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() final;
49
59 int open(file_handle file);
60
69 int bind(const std::string &name);
70
81 int connect(const std::string &name);
82
88 std::string sock() const noexcept;
89
96 std::string peer() const noexcept;
97
107 void pending(int count) noexcept;
108
113 int pending() noexcept;
114
131 handle_type receive() noexcept;
132
150 int chmod(chmod_flags flags) noexcept;
151
152private:
153 bool ipc;
154};
155
156} // namespace uvw
157
158#ifndef UVW_AS_LIB
159# include "pipe.cpp"
160#endif
161
162#endif // UVW_PIPE_INCLUDE_H
The pipe handle.
Definition: pipe.h:38
int open(file_handle file)
Opens an existing file descriptor or HANDLE as a pipe.
int pending() noexcept
Gets the number of pending pipe this instance can 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)
Connects to the Unix domain socket or the named pipe.
int bind(const std::string &name)
bind Binds the pipe to a file path (Unix) or a name (Windows).
std::string sock() const noexcept
Gets the name of the Unix domain socket or the named pipe.
int init() final
Initializes the 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::uv_type_wrapper< uv_file > file_handle
Definition: util.h:85