TcpTextStream Class Reference

Class for encapsulating a Socket Stream. More...

Inherits basic_iostream.

List of all members.

Public Member Functions

 TcpTextStream (const std::string &serverHostAddress, const std::string &port, unsigned int timeout, SmartUtil::ConversionCodepage::Codepage codepage=SmartUtil::ConversionCodepage::UTF8)
 Constructor creating a TcpTextStream.


Detailed Description

Class for encapsulating a Socket Stream.

Use the class as a normal "std::iostream" object. You can write to the stream using the "insertion operator" (<<) and read from the stream using the "extraction operator". (>>) Class encapsulates a SOCKET and functions like a both readable and writable stream. However logic on the server side will always make the stream either ready for "writing" or "reading". Like for instance an HTTP request will always expect the client to first send a (complete) HTTP request and then read the (complete) response before trying to send another request on the same socket!


Constructor & Destructor Documentation

TcpTextStream ( const std::string &  serverHostAddress,
const std::string &  port,
unsigned int  timeout,
SmartUtil::ConversionCodepage::Codepage  codepage = SmartUtil::ConversionCodepage::UTF8 
)

Constructor creating a TcpTextStream.

The serverHostName should be e.g. "www.google.com" or "localhost", the port should be the port you expect to use and the timeout is the amount of seconds we wait after starting a "read action" before we give up and throws an exception. Stream is synchronous meaning if you need asynchronous access you need to wrap it yourself!

Back to SmartWin website
SourceForge.net Logo