uvw 3.1.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
uvw::pipe_handle Class Referencefinal

The pipe handle. More...

#include <pipe.h>

Inheritance diagram for uvw::pipe_handle:
Inheritance graph
[legend]
Collaboration diagram for uvw::pipe_handle:
Collaboration graph
[legend]

Public Member Functions

int init () final
 Initializes the handle.
 
int open (file_handle file)
 Opens an existing file descriptor or HANDLE as a pipe.
 
int bind (const std::string &name)
 bind Binds the pipe to a file path (Unix) or a name (Windows).
 
int connect (const std::string &name)
 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.
 
std::string peer () const noexcept
 Gets the name of the Unix domain socket or the named pipe to which the handle is connected.
 
void pending (int count) noexcept
 Sets the number of pending pipe this instance can handle.
 
int pending () noexcept
 Gets the number of pending pipe this instance can handle.
 
handle_type receive () noexcept
 Used to receive handles over IPC pipes.
 
int chmod (chmod_flags flags) noexcept
 Alters pipe permissions.
 
- Public Member Functions inherited from uvw::stream_handle< pipe_handle, uv_pipe_t >
int shutdown ()
 Shutdowns the outgoing (write) side of a duplex stream.
 
int listen (int backlog=DEFAULT_BACKLOG)
 Starts listening for incoming connections.
 
int accept (S &ref)
 Accepts incoming connections.
 
int read ()
 Starts reading data from an incoming stream.
 
int stop ()
 Stops reading data from the stream.
 
int write (std::unique_ptr< char[], Deleter > data, unsigned int len)
 Writes data to the stream.
 
int write (char *data, unsigned int len)
 Writes data to the stream.
 
int write (S &send, std::unique_ptr< char[], Deleter > data, unsigned int len)
 Extended write function for sending handles over a pipe handle.
 
int write (S &send, char *data, unsigned int len)
 Extended write function for sending handles over a pipe handle.
 
int try_write (std::unique_ptr< char[]> data, unsigned int len)
 Queues a write request if it can be completed immediately.
 
int try_write (std::unique_ptr< char[]> data, unsigned int len, stream_handle< V, W > &send)
 Queues a write request if it can be completed immediately.
 
int try_write (char *data, unsigned int len)
 Queues a write request if it can be completed immediately.
 
int try_write (char *data, unsigned int len, stream_handle< V, W > &send)
 Queues a write request if it can be completed immediately.
 
bool readable () const noexcept
 Checks if the stream is readable.
 
bool writable () const noexcept
 Checks if the stream is writable.
 
bool blocking (bool enable=false)
 Enables or disables blocking mode for a stream.
 
size_t write_queue_size () const noexcept
 Gets the amount of queued bytes waiting to be sent.
 
- Public Member Functions inherited from uvw::handle< T, U, E >
handle_category category () const noexcept
 Gets the category of the handle.
 
handle_type type () const noexcept
 Gets the type of the handle.
 
bool active () const noexcept
 Checks if the handle is active.
 
bool closing () const noexcept
 Checks if a handle is closing or closed.
 
void close () noexcept
 Request handle to be closed.
 
void reference () noexcept
 Reference the given handle.
 
void unreference () noexcept
 Unreference the given handle.
 
bool referenced () const noexcept
 Checks if the given handle referenced.
 
std::size_t size () const noexcept
 Returns the size of the underlying handle type.
 
int send_buffer_size ()
 Gets the size of the send buffer used for the socket.
 
int send_buffer_size (int value)
 Sets the size of the send buffer used for the socket.
 
int recv_buffer_size ()
 Gets the size of the receive buffer used for the socket.
 
int recv_buffer_size (int value)
 Sets the size of the receive buffer used for the socket.
 
os_file_descriptor fd () const
 Gets the platform dependent file descriptor equivalent.
 
- Public Member Functions inherited from uvw::resource< T, U, close_event, E... >
std::shared_ptr< R > data () const
 Gets user-defined data. uvw won't use this field in any case.
 
void data (std::shared_ptr< void > udata)
 Sets arbitrary data. uvw won't use this field in any case.
 
- Public Member Functions inherited from uvw::uv_type< U >
virtual int init ()
 Initializes the handle.
 
loopparent () const noexcept
 Gets the loop from which the resource was originated.
 
const U * raw () const noexcept
 Gets the underlying raw data structure.
 
U * raw () noexcept
 Gets the underlying raw data structure.
 
- Public Member Functions inherited from uvw::emitter< T, E... >
void on (listener_t< U > f)
 Registers a long-lived listener with the event emitter.
 
void reset () noexcept
 Disconnects the listener for the given event type.
 
void reset () noexcept
 Disconnects all listeners.
 
bool has () const noexcept
 Checks if there is a listener registered for the specific event.
 

Detailed Description

The pipe handle.

Pipe handles provide an abstraction over local domain sockets on Unix and named pipes on Windows.

To create a pipe_handle through a loop, arguments follow:

Definition at line 38 of file pipe.h.

Member Function Documentation

◆ bind()

int uvw::pipe_handle::bind ( const std::string &  name)

bind Binds the pipe to a file path (Unix) or a name (Windows).

Paths on Unix get truncated typically between 92 and 108 bytes.

Parameters
nameA valid file path.
Returns
Underlying return value.

◆ chmod()

int uvw::pipe_handle::chmod ( chmod_flags  flags)
noexcept

Alters pipe permissions.

It allows the pipe to be accessed from processes run by different users.

Available flags are:

  • pipe_handle::chmod_flags::READABLE
  • pipe_handle::chmod_flags::WRITABLE

See the official documentation for further details.

Parameters
flagsA valid set of flags.
Returns
Underlying return value.

◆ connect()

int uvw::pipe_handle::connect ( const std::string &  name)

Connects to the Unix domain socket or the named pipe.

Paths on Unix get truncated typically between 92 and 108 bytes.
A connect event is emitted when the connection has been established.

Parameters
nameA valid domain socket or named pipe.
Returns
Underlying return value.

◆ init()

int uvw::pipe_handle::init ( )
finalvirtual

Initializes the handle.

Returns
Underlying return value.

Reimplemented from uvw::uv_type< U >.

◆ open()

int uvw::pipe_handle::open ( file_handle  file)

Opens an existing file descriptor or HANDLE as a pipe.

The passed file descriptor or HANDLE is not checked for its type, but it’s required that it represents a valid pipe.

Parameters
fileA valid file handle (either a file descriptor or a HANDLE).
Returns
Underlying return value.

◆ peer()

std::string uvw::pipe_handle::peer ( ) const
noexcept

Gets the name of the Unix domain socket or the named pipe to which the handle is connected.

Returns
The name of the Unix domain socket or the named pipe to which the handle is connected, an empty string in case of errors.

◆ pending() [1/2]

int uvw::pipe_handle::pending ( )
noexcept

Gets the number of pending pipe this instance can handle.

Returns
The number of pending pipe this instance can handle.

◆ pending() [2/2]

void uvw::pipe_handle::pending ( int  count)
noexcept

Sets the number of pending pipe this instance can handle.

This method can be used to set the number of pending pipe this instance handles when the pipe server is waiting for connections.
Note that this setting applies to Windows only.

Parameters
countThe number of accepted pending pipe.

◆ receive()

handle_type uvw::pipe_handle::receive ( )
noexcept

Used to receive handles over IPC pipes.

Steps to be done:

  • Call pending(), if it’s greater than zero then proceed.
  • Initialize a handle of the given type, as returned by receive().
  • Call accept(pipe, handle).
Returns
The type of the pending handle. Possible values are:
  • handle_type::PIPE
  • handle_type::TCP
  • handle_type::UDP
  • handle_type::UNKNOWN

◆ sock()

std::string uvw::pipe_handle::sock ( ) const
noexcept

Gets the name of the Unix domain socket or the named pipe.

Returns
The name of the Unix domain socket or the named pipe, an empty string in case of errors.

The documentation for this class was generated from the following file: