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

# tcpstream(3cc)

A more natural C++ 'tcpstream' class for use by non-threaded applications. C++ 'fstream' style tcpstream class.

## NAME

tcpstream - A more natural C++ 'tcpstream' class for use by non-threaded applications. C++ 'fstream' style tcpstream class.

## SYNOPSIS

`#include <socket.h>`

Inherits **TCPStream**.

Inherited by **iftpstream**, and **oftpstream**.

### Public Methods

**tcpstream** (const tcpstream &rhs)\
 **tcpstream** ()\
 *Construct an unopened 'tcpstream' object.* **tcpstream** (const char \*addr, int buffer=512)\
 *Construct and 'open' (connect) the tcp stream to a remote socket.* **tcpstream** (**TCPSocket** &tcp, int buffer=512)\
 *Construct and 'accept' (connect) the tcp stream through a server.* void **open** (const char \*addr, int buffer=512)\
 *Open a tcp stream connection.* void **open** (**TCPSocket** &tcp, int buffer=512)\
 *Open a tcp stream connection by accepting a tcp socket.* void **close** (void)\
 *Close the active tcp stream connection.* bool **operator!** () const\
 *Test to see if stream is open.*

## DETAILED DESCRIPTION

A more natural C++ 'tcpstream' class for use by non-threaded applications. C++ 'fstream' style tcpstream class.

This class behaves a lot more like fstream and similar classes.

**Author:**  David Sugar \<dyfet@ostel.com\>

## CONSTRUCTOR & DESTRUCTOR DOCUMENTATION

### tcpstream::tcpstream (const tcpstream & rhs)` [inline]`

### tcpstream::tcpstream ()

Construct an unopened 'tcpstream' object.

### tcpstream::tcpstream (const char \* addr, int buffer = 512)

Construct and 'open' (connect) the tcp stream to a remote socket.

**Parameters:**

- *addr*

  *string address in form addr:port.*

- *buffer*

  *size for streaming (optional).*

### tcpstream::tcpstream (TCPSocket & tcp, int buffer = 512)

*Construct and 'accept' (connect) the tcp stream through a server.*

**Parameters:**

- *tcp*

  *socket to accept from.*

- *buffer*

  *size for streaming (optional).*

## MEMBER FUNCTION DOCUMENTATION

### void tcpstream::close (void)

*Close the active tcp stream connection.*

*Reimplemented in* **oftpstream***, and* **iftpstream***.*

### void tcpstream::open (TCPSocket & tcp, int buffer = 512)

*Open a tcp stream connection by accepting a tcp socket.*

**Parameters:**

- *tcp*

  *socket to accept from.*

- *buffer*

  *size for streaming (optional)*

### void tcpstream::open (const char \* addr, int buffer = 512)

*Open a tcp stream connection.*

*This will close the currently active connection first.*

**Parameters:**

- *addr*

  *string address in form addr:port.*

- *buffer*

  *size for streaming (optional)*

### bool tcpstream::operator! ()

*Test to see if stream is open.*

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

## AUTHOR

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