pipe


The os_pipe class provides a portable interface for reliable pipe communications between a server pipe and a client pipe. The server constructs an os_pipe_connection_server and names it with a value that is known to its client. The server then waits for an incoming connection request using accept() . A client creates a pipe and connects it to the server pipe using connect_to() . When the connection is made, the server's accept() function connects its pipe argument to the client pipe. Data written to the server pipe appears as input to the client pipe; data written to the client pipe appears as input to the server pipe.

Library

Pipe<ToolKit>

Declaration

#include <ospace/pipe/pipe.h>

class os_pipe

Interface

Constructor
os_pipe()
Constructs a disconnected pipe.

Throws: os_pipe_toolkit_error

Constructor
os_pipe( const char* path , enum Encoding enc = Ascii )
Constructs a pipe connected to the named pipe at path . Default enc is Ascii. Valid value for enc can be Ascii or Utf8.

Throws: os_pipe_toolkit_error

Constructor
os_pipe( const string& path , enum Encoding enc = Ascii )
Constructs a pipe connected to the named pipe at path . Default enc is Ascii. Valid value for enc can be Ascii or Utf8.

Throws: os_pipe_toolkit_error

Constructor
os_pipe( os_desc_t descriptor )
Constructs a pipe connected to the pipe descriptor .
Destructor
~os_pipe()
Destroys the pipe, closing the underlying descriptor if necessary.
<
bool operator<( const os_pipe& pipe ) const
Returns true if this pipe's descriptor value is less than pipe 's.
==
bool operator==( const os_pipe& pipe ) const
Returns true if this pipe's descriptor value is the same as pipe 's.
(os_adapter)
operator os_adapter() const
Returns an os_adapter to the pipe.
(os_desc_t)
operator os_desc_t() const
Returns the native pipe descriptor.
auto_close
void auto_close( bool flag )
If flag is true , closes the descriptor on destruction.
auto_close
bool auto_close() const
Returns true if the pipe will close its descriptor on destruction.
clear
void clear()
Resets the state to good.
close
void close()
Closes the pipe.

Throws: os_pipe_toolkit_error

connect_to
void connect_to( const string& path , enum Encoding enc = Ascii )
Connects to the pipe specified by path . Default enc is Ascii. Valid value for enc can be Ascii or Utf8.

Throws: os_pipe_toolkit_error

descriptor
void descriptor( os_desc_t descriptor )
Sets the native pipe descriptor to descriptor .
descriptor
os_desc_t descriptor() const
Returns the value of the native pipe descriptor.
eof
bool eof() const
Returns true if the pipe is at end of input.
event_on_eof
void event_on_eof( bool flag )
If flag is true , the pipe generates an event on EOF.
event_on_eof
bool event_on_eof() const
Returns true if the pipe will generate an event on EOF.
good
bool good() const
Returns true if the pipe is in a good state and not at EOF.
ok
bool ok() const
Returns true if the pipe is in a good state.
is_open
bool is_open() const
Returns true if the pipe is open.
path
string path() const
Returns the path to this pipe.
read
ssize_t read( void* buffer , size_t bytes )
Reads up to the specified number of bytes of data into buffer from the pipe. Returns the number of bytes actually read or returns -1 on error.

Throws: os_pipe_toolkit_error

reset
void reset()
Destroys the existing underlying pipe and replaces it with a newly-constructed pipe.

Throws: os_pipe_toolkit_error

write
ssize_t write( const void* buffer , size_t bytes )
Writes up to the specified number of bytes of data from buffer to the pipe. Returns the number of bytes written or returns -1 on error.

Throws: os_pipe_toolkit_error


Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.