uvw 2.12.1
Loading...
Searching...
No Matches
uvw::PipeHandle Class Referencefinal

The PipeHandle handle. More...

#include <pipe.h>

Inheritance diagram for uvw::PipeHandle:
Collaboration diagram for uvw::PipeHandle:

Public Member Functions

bool init ()
 Initializes the handle.
 
void open (FileHandle file)
 Opens an existing file descriptor or HANDLE as a pipe.
 
void bind (const std::string &name)
 bind Binds the pipe to a file path (Unix) or a name (Windows).
 
void 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.
 
HandleType receive () noexcept
 Used to receive handles over IPC pipes.
 
bool chmod (Flags< Chmod > flags) noexcept
 Alters pipe permissions.
 
- Public Member Functions inherited from uvw::StreamHandle< PipeHandle, uv_pipe_t >
void shutdown ()
 Shutdowns the outgoing (write) side of a duplex stream.
 
void listen (int backlog=DEFAULT_BACKLOG)
 Starts listening for incoming connections.
 
void accept (S &ref)
 Accepts incoming connections.
 
void read ()
 Starts reading data from an incoming stream.
 
void stop ()
 Stops reading data from the stream.
 
void write (std::unique_ptr< char[], Deleter > data, unsigned int len)
 Writes data to the stream.
 
void write (char *data, unsigned int len)
 Writes data to the stream.
 
void write (S &send, std::unique_ptr< char[], Deleter > data, unsigned int len)
 Extended write function for sending handles over a pipe handle.
 
void write (S &send, char *data, unsigned int len)
 Extended write function for sending handles over a pipe handle.
 
int tryWrite (std::unique_ptr< char[]> data, unsigned int len)
 Queues a write request if it can be completed immediately.
 
int tryWrite (std::unique_ptr< char[]> data, unsigned int len, StreamHandle< V, W > &send)
 Queues a write request if it can be completed immediately.
 
int tryWrite (char *data, unsigned int len)
 Queues a write request if it can be completed immediately.
 
int tryWrite (char *data, unsigned int len, StreamHandle< 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 writeQueueSize () const noexcept
 Gets the amount of queued bytes waiting to be sent.
 
- Public Member Functions inherited from uvw::Handle< PipeHandle, uv_pipe_t >
HandleCategory category () const noexcept
 Gets the category of the handle.
 
HandleType 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 sendBufferSize ()
 Gets the size of the send buffer used for the socket.
 
bool sendBufferSize (int value)
 Sets the size of the send buffer used for the socket.
 
int recvBufferSize ()
 Gets the size of the receive buffer used for the socket.
 
bool recvBufferSize (int value)
 Sets the size of the receive buffer used for the socket.
 
OSFileDescriptor fd () const
 Gets the platform dependent file descriptor equivalent.
 
- Public Member Functions inherited from uvw::Resource< PipeHandle, uv_pipe_t >
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::UnderlyingType< PipeHandle, uv_pipe_t >
Looploop () const noexcept
 Gets the loop from which the resource was originated.
 
const uv_pipe_t * raw () const noexcept
 Gets the underlying raw data structure.
 
uv_pipe_t * raw () noexcept
 Gets the underlying raw data structure.
 
- Public Member Functions inherited from uvw::Emitter< PipeHandle >
Connection< E > on (Listener< E > f)
 Registers a long-lived listener with the event emitter.
 
Connection< E > once (Listener< E > f)
 Registers a short-lived listener with the event emitter.
 
void erase (Connection< E > conn) noexcept
 Disconnects a listener from the event emitter.
 
void clear () noexcept
 Disconnects all the listeners for the given event type.
 
void clear () noexcept
 Disconnects all the listeners.
 
bool empty () const noexcept
 Checks if there are listeners registered for the specific event.
 
bool empty () const noexcept
 Checks if there are listeners registered with the event emitter.
 

Additional Inherited Members

- Public Types inherited from uvw::Emitter< PipeHandle >
- Static Public Member Functions inherited from uvw::UnderlyingType< PipeHandle, uv_pipe_t >
static std::shared_ptr< PipeHandlecreate (Args &&...args)
 Creates a new resource of the given type.
 
- Protected Types inherited from uvw::Resource< PipeHandle, uv_pipe_t >
- Protected Member Functions inherited from uvw::Handle< PipeHandle, uv_pipe_t >
- Protected Member Functions inherited from uvw::Resource< PipeHandle, uv_pipe_t >
- Protected Member Functions inherited from uvw::UnderlyingType< PipeHandle, uv_pipe_t >
- Protected Member Functions inherited from uvw::Emitter< PipeHandle >
- Static Protected Member Functions inherited from uvw::Handle< PipeHandle, uv_pipe_t >

Detailed Description

The PipeHandle handle.

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

To create a PipeHandle through a Loop, arguments follow:

  • An optional boolean value that indicates if this pipe will be used for handle passing between processes.

Definition at line 35 of file pipe.h.

Member Function Documentation

◆ bind()

void uvw::PipeHandle::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.
An ErrorEvent event is emitted in case of errors.

Parameters
nameA valid file path.

◆ chmod()

bool uvw::PipeHandle::chmod ( Flags< Chmod > flags)
noexcept

Alters pipe permissions.

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

Available flags are:

  • PipeHandle::Chmod::READABLE
  • PipeHandle::Chmod::WRITABLE

See the official documentation for further details.

Parameters
flagsA valid set of flags.
Returns
True in case of success, false otherwise.

◆ connect()

void uvw::PipeHandle::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 ConnectEvent event is emitted when the connection has been established.
An ErrorEvent event is emitted in case of errors during the connection.

Parameters
nameA valid domain socket or named pipe.

◆ init()

bool uvw::PipeHandle::init ( )

Initializes the handle.

Returns
True in case of success, false otherwise.

◆ open()

void uvw::PipeHandle::open ( FileHandle 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.
An ErrorEvent event is emitted in case of errors.

Parameters
fileA valid file handle (either a file descriptor or a HANDLE).

◆ peer()

std::string uvw::PipeHandle::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::PipeHandle::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::PipeHandle::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()

HandleType uvw::PipeHandle::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:
  • HandleType::PIPE
  • HandleType::TCP
  • HandleType::UDP
  • HandleType::UNKNOWN

◆ sock()

std::string uvw::PipeHandle::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: