ucommon
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
ucommon::pipestream Class Reference

Streamable tcp connection between client and server. More...

#include <stream.h>

Inheritance diagram for ucommon::pipestream:
Inheritance graph
[legend]
Collaboration diagram for ucommon::pipestream:
Collaboration graph
[legend]

Public Types

enum  access_t { RDONLY, WRONLY, RDWR }

Public Member Functions

void close (void)
 Close an active stream connection.
void open (char *command, access_t access, char **env=((void *) 0), size_t buffering=512)
 Open a stream connection to a pipe service.
 operator bool ()
 See if stream connection is active.
bool operator! ()
 See if stream is disconnected.
 pipestream ()
 Create an unopened pipe stream.
 pipestream (char *command, access_t access, char **env=((void *) 0), size_t size=512)
 Create child process and start pipe.
void terminate (void)
 Force terminate child and close.
virtual ~pipestream ()
 Destroy a pipe stream.
- Public Member Functions inherited from ucommon::StreamProtocol
bool is_open (void)
int sync (void)
 Flush the stream input and output buffers, writes pending output.
- Public Member Functions inherited from ucommon::CharacterProtocol
int get (void)
 Get the next character.
int put (int code)
 Put the next character.

Protected Member Functions

int _getch (void)
 This streambuf method is used to load the input buffer through the established pipe connection.
int _putch (int ch)
 This streambuf method is used to write the output buffer through the established pipe connection.
void release (void)
 Release the stream, detach/do not wait for the process.
- Protected Member Functions inherited from ucommon::StreamProtocol
void allocate (size_t size)
int overflow (int code)
int uflow ()
 This streambuf method is used for doing unbuffered reads through the establish tcp socket connection when in interactive mode.
int underflow ()

Protected Attributes

pid_t pid
fsys_t rd
fsys_t wr
- Protected Attributes inherited from ucommon::StreamProtocol
size_t bufsize
char * gbuf
char * pbuf

Detailed Description

Streamable tcp connection between client and server.

The tcp stream class can represent a client connection to a server or an instance of a service generated by a tcp listener. As a stream class, data can be manipulated using the << and >> operators.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 230 of file stream.h.

Constructor & Destructor Documentation

ucommon::pipestream::pipestream ( char *  command,
access_t  access,
char **  env = ((void *) 0),
size_t  size = 512 
)

Create child process and start pipe.

Parameters
commandto pass.
accessmode of pipe stream.
envto create in child.
sizeof buffer.

Member Function Documentation

int ucommon::pipestream::_getch ( void  )
protectedvirtual

This streambuf method is used to load the input buffer through the established pipe connection.

Returns
char from get buffer, EOF if not connected.

Implements ucommon::CharacterProtocol.

int ucommon::pipestream::_putch ( int  ch)
protectedvirtual

This streambuf method is used to write the output buffer through the established pipe connection.

Parameters
chchar to push through.
Returns
char pushed through.

Implements ucommon::CharacterProtocol.

void ucommon::pipestream::close ( void  )

Close an active stream connection.

This waits for the child to terminate.

void ucommon::pipestream::open ( char *  command,
access_t  access,
char **  env = ((void *) 0),
size_t  buffering = 512 
)

Open a stream connection to a pipe service.

Parameters
commandto execute.
accessmode of stream.
envto create in child process.
bufferingsize to use.
ucommon::pipestream::operator bool ( )
inline

See if stream connection is active.

Returns
true if stream is active.

Reimplemented from ucommon::StreamProtocol.

Definition at line 292 of file stream.h.

bool ucommon::pipestream::operator! ( )
inline

See if stream is disconnected.

Returns
true if stream disconnected.

Reimplemented from ucommon::StreamProtocol.

Definition at line 299 of file stream.h.


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