|
|
TCP streams are used to represent TCP client connections to a server by TCP protocol servers for accepting client connections. The TCP stream is a C++ "stream" class, and can accept streaming of data to and from other C++ objects using the << and >> operators.
TCPStream itself can be formed either by connecting to a bound network address of a TCP server, or can be created when "accepting" a network connection from a TCP server.
timeout_t timeout | timeout |
[protected]
int bufsize | bufsize |
[protected]
char * gbuf | gbuf |
[protected]
char * pbuf | pbuf |
[protected]
TCPStream (bool throwflag = true)
| TCPStream |
[protected]
The constructor required for "tcpstream", a more C++ style version of the TCPStream class.
void Allocate (int size)
| Allocate |
[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 endStream (void)
| endStream |
[protected]
Used to terminate the buffer space and cleanup the socket connection. This fucntion is called by the destructor.
int underflow (void)
| underflow |
[protected virtual]
This streambuf method is used to load the input buffer through the established tcp socket connection.
Returns: char from get buffer, EOF if not connected.
int uflow (void)
| uflow |
[protected]
This streambuf method is used for doing unbuffered reads through the establish tcp socket connection when in interactive mode. Also this method will handle proper use of buffers if not in interative mode.
Returns: char from tcp socket connection, EOF if not connected.
int overflow (int ch)
| overflow |
[protected]
This streambuf method is used to write the output buffer through the established tcp connection.
Parameters:
char | to push through. |
Returns: char pushed through.
void Connect (const InetHostAddress &host, tpport_t port, int size)
| Connect |
[protected]
Create a TCP stream by connecting to a TCP socket (on a remote machine).
Parameters:
host | address of remote TCP server. |
port | number to connect. |
size | of streaming input and output buffers. |
std::iostream * tcp (void)
| tcp |
[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.
TCPStream (TCPSocket &server, int size = 512, bool throwflag = true, timeout_t timeout = 0)
| TCPStream |
Create a TCP stream by accepting a connection from a bound TCP socket acting as a server. This performs an "accept" call.
Parameters:
size | of streaming input and output buffers. |
flag | to throw errors. |
timeout | for all operations. |
TCPStream (const InetHostAddress &host, tpport_t port, int size = 512, bool throwflag = true, timeout_t to = 0)
| TCPStream |
Create a TCP stream by connecting to a TCP socket (on a remote machine).
Parameters:
host | address of remote TCP server. |
port | number to connect. |
size | of streaming input and output buffers. |
flag | to throw errors. |
timeout | for all operations. |
inline void setTimeout (timeout_t to)
| setTimeout |
Set the I/O operation timeout for socket I/O operations.
Parameters:
timeout | to set. |
TCPStream (const TCPStream &source)
| TCPStream |
A copy constructor creates a new stream buffer.
Parameters:
source | of copy. |
~TCPStream ()
| ~TCPStream |
[virtual]
Flush and empty all buffers, and then remove the allocated buffers.
int sync (void)
| sync |
Flushes the stream input and output buffers, writes pending output.
Returns: 0 on success.
bool isPending (sockpend_t pend, timeout_t timeout = TIMEOUT_INF)
| isPending |
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 getBufferSize (void)
| getBufferSize |
[const]
Return the size of the current stream buffering used.
Returns: size of stream buffers.