---
name: "UnixStream"
section: "3cc"
platform: "linux"
package: "libcommoncpp2-dev"
version: "1.0.13-5"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/UnixStream"
---

# UnixStream(3cc)

Unix streams are used to represent Unix domain client connections to a local server for accepting client connections. streamable Unix domain socket connection.

## NAME

UnixStream - Unix streams are used to represent Unix domain client connections to a local server for accepting client connections. streamable Unix domain socket connection.

## SYNOPSIS

`#include <unix.h>`

Inherits **Socket**.

Inherited by **UnixSession**, and **unixstream**.

### Public Methods

**UnixStream** (**UnixSocket** &server, int **size**=512, bool throwflag=true, **timeout\_t** **timeout**=0)\
 *Create a Unix domain stream by accepting a connection from a bound Unix domain socket acting as a server.* **UnixStream** (const char \*pathname, int **size**=512, bool throwflag=true, **timeout\_t** to=0)\
 *Create a Unix domain stream by connecting to a Unix domain socket.* void **setTimeout** (**timeout\_t** to)\
 *Set the I/O operation timeout for socket I/O operations.* **UnixStream** (const UnixStream &source)\
 *A copy constructor creates a new stream buffer.* virtual **~UnixStream** ()\
 *Flush and empty all buffers, and then remove the allocated buffers.* int **sync** (void)\
 *Flushes the stream input and output buffers, writes pending output.* bool **isPending** (**Pending** pend, **timeout\_t** **timeout**=TIMEOUT\_INF)\
 *Get the status of pending stream data.* int **getBufferSize** (void) const\
 *Return the size of the current stream buffering used.*

### Protected Methods

**UnixStream** (bool throwflag=true)\
 *The constructor required for 'unixstream', a more C++ style version of the* **TCPStream** *class.* void **allocate** (int **size**)\
 *Used to allocate the buffer space needed for iostream operations.* void **endStream** (void)\
 *Used to terminate the buffer space and cleanup the socket connection.* virtual int **underflow** (void)\
 *This streambuf method is used to load the input buffer through the established unix domain socket connection.* int **uflow** (void)\
 *This streambuf method is used for doing unbuffered reads through the established unix domain socket connection when in interactive mode.* int **overflow** (int ch)\
 *This streambuf method is used to write the output buffer through the established unix domain connection.* void **connect** (const char \*pathname, int **size**)\
 *Create a Unix domain stream by connecting to a Unix domain socket.* std::iostream \* **unixstr** (void)\
 *Used in derived classes to refer to the current object via it's iostream.*

### Protected Attributes

**timeout\_t** **timeout**\
 int **bufsize**\
 char \* **gbuf**\
 char \* **pbuf**\

## DETAILED DESCRIPTION

Unix streams are used to represent Unix domain client connections to a local server for accepting client connections. streamable Unix domain socket connection.

The Unix stream is a C++ 'stream' class, and can accept streaming of data to and from other C++ objects using the \<\< and \>\> operators.

Unix Stream itself can be formed either by connecting to a bound network address of a Unix domain server, or can be created when 'accepting' a network connection from a Unix domain server.

**Author:**  Alex Pavloff \<alex@pavloff.net\>

## CONSTRUCTOR & DESTRUCTOR DOCUMENTATION

### UnixStream::UnixStream (bool throwflag = true)` [protected]`

The constructor required for 'unixstream', a more C++ style version of the **TCPStream** class.

### UnixStream::UnixStream (UnixSocket & server, int size = 512, bool throwflag = true, timeout\_t timeout = 0)

Create a Unix domain stream by accepting a connection from a bound Unix domain socket acting as a server.

This performs an 'accept' call.

**Parameters:**

- *server*

  *socket listening.*

- *size*

  *of streaming input and output buffers.*

- *throwflag*

  *flag to throw errors.*

- *timeout*

  *for all operations.*

### UnixStream::UnixStream (const char \* pathname, int size = 512, bool throwflag = true, timeout\_t to = 0)

*Create a Unix domain stream by connecting to a Unix domain socket.*

**Parameters:**

- *pathname*

  *path to socket*

- *size*

  *of streaming input and output buffers.*

- *throwflag*

  *flag to throw errors.*

- *to*

  *timeout for all operations.*

### UnixStream::UnixStream (const UnixStream & source)

*A copy constructor creates a new stream buffer.*

**Parameters:**

- *source*

  *of copy.*

### virtual UnixStream::~UnixStream ()` [inline, virtual]`

*Flush and empty all buffers, and then remove the allocated buffers.*

## MEMBER FUNCTION DOCUMENTATION

### void UnixStream::allocate (int size)` [protected]`

*Used to allocate the buffer space needed for iostream operations.*

*This function is called by the constructor.*

**Parameters:**

- *size*

  *of stream buffers from constructor.*

### void UnixStream::connect (const char \* pathname, int size)` [protected]`

*Create a Unix domain stream by connecting to a Unix domain socket.*

**Parameters:**

- *pathname*

  *path to socket*

- *size*

  *of streaming input and output buffers.*

### void UnixStream::endStream (void)` [protected]`

*Used to terminate the buffer space and cleanup the socket connection.*

*This fucntion is called by the destructor.*

### int UnixStream::getBufferSize (void) const` [inline]`

*Return the size of the current stream buffering used.*

**Returns:**  *size of stream buffers.*

### bool UnixStream::isPending (Pending pend, timeout\_t timeout = TIMEOUT\_INF)` [virtual]`

*Get the status of pending stream data.*

*This can be used to examine if input or output is waiting, or if an error or disconnect has occured on the stream. If a read buffer contains data then input is ready and if write buffer contains data it is first flushed and then checked.*

*Reimplemented from* **Socket***.*

### int UnixStream::overflow (int ch)` [protected]`

*This streambuf method is used to write the output buffer through the established unix domain connection.*

**Parameters:**

- *ch*

  *char to push through.*

**Returns:**  *char pushed through.*

### void UnixStream::setTimeout (timeout\_t to)` [inline]`

*Set the I/O operation timeout for socket I/O operations.*

**Parameters:**

- *to*

  *timeout to set.*

### int UnixStream::sync (void)

*Flushes the stream input and output buffers, writes pending output.*

**Returns:**  *0 on success.*

### int UnixStream::uflow (void)` [protected]`

*This streambuf method is used for doing unbuffered reads through the established unix domain socket connection when in interactive mode.*

*Also this method will handle proper use of buffers if not in interative mode.*

**Returns:**  *char from unix domain socket connection, EOF if not connected.*

### virtual int UnixStream::underflow (void)` [protected, virtual]`

*This streambuf method is used to load the input buffer through the established unix domain socket connection.*

**Returns:**  *char from get buffer, EOF if not connected.*

### std::iostream\* UnixStream::unixstr (void)` [inline, protected]`

*Used in derived classes to refer to the current object via it's iostream.*

*For example, to send a set of characters in a derived method, one might use \*tcp() \<\< 'test'.*

**Returns:**  *stream pointer of this object.*

## MEMBER DATA DOCUMENTATION

### int UnixStream::bufsize` [protected]`

### char\* UnixStream::gbuf` [protected]`

### char \* UnixStream::pbuf` [protected]`

### timeout\_t UnixStream::timeout` [protected]`

## AUTHOR

*Generated automatically by Doxygen for CommonC++ from the source code.*
