PionNetworkLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pion::tcp::stream Class Reference

#include <stream.hpp>

Inheritance diagram for pion::tcp::stream:
Collaboration diagram for pion::tcp::stream:

Public Types

typedef char char_type
 
typedef std::char_traits< char >
::int_type 
int_type
 
typedef std::char_traits< char >
::off_type 
off_type
 
typedef std::char_traits< char >
::pos_type 
pos_type
 
typedef std::char_traits< char > traits_type
 

Public Member Functions

 stream (const tcp::connection_ptr &conn_ptr)
 
 stream (boost::asio::io_service &io_service, const bool ssl_flag=false)
 
 stream (boost::asio::io_service &io_service, connection::ssl_context_type &ssl_context)
 
boost::system::error_code accept (boost::asio::ip::tcp::acceptor &tcp_acceptor)
 
boost::system::error_code connect (boost::asio::ip::tcp::endpoint &tcp_endpoint)
 
boost::system::error_code connect (const boost::asio::ip::address &remote_addr, const unsigned int remote_port)
 
void close (void)
 closes the tcp connection More...
 
bool is_open (void) const
 returns true if the connection is currently open More...
 
bool get_ssl_flag (void) const
 returns true if the connection is encrypted using SSL More...
 
boost::asio::ip::address get_remote_ip (void) const
 returns the client's IP address More...
 
stream_bufferrdbuf (void)
 returns a pointer to the stream buffer in use More...
 

Detailed Description

stream: std::basic_iostream wrapper for TCP network connections

Member Typedef Documentation

typedef std::char_traits<char>::int_type pion::tcp::stream::int_type
typedef std::char_traits<char>::off_type pion::tcp::stream::off_type
typedef std::char_traits<char>::pos_type pion::tcp::stream::pos_type
typedef std::char_traits<char> pion::tcp::stream::traits_type

Constructor & Destructor Documentation

pion::tcp::stream::stream ( const tcp::connection_ptr conn_ptr)
inlineexplicit

constructs a TCP stream object for an existing TCP connection

Parameters
conn_ptrpointer to the TCP connection to use for reading & writing
pion::tcp::stream::stream ( boost::asio::io_service &  io_service,
const bool  ssl_flag = false 
)
inlineexplicit

constructs a TCP stream object for a new TCP connection

Parameters
io_serviceasio service associated with the connection
ssl_flagif true then the connection will be encrypted using SSL
pion::tcp::stream::stream ( boost::asio::io_service &  io_service,
connection::ssl_context_type ssl_context 
)
inline

constructs a TCP stream object for a new SSL/TCP connection

Parameters
io_serviceasio service associated with the connection
ssl_contextasio ssl context associated with the connection

Member Function Documentation

boost::system::error_code pion::tcp::stream::accept ( boost::asio::ip::tcp::acceptor &  tcp_acceptor)
inline

accepts a new tcp connection and performs SSL handshake if necessary

Parameters
tcp_acceptorobject used to accept new connections
Returns
boost::system::error_code contains error code if the connection fails
See Also
boost::asio::basic_socket_acceptor::accept()

References pion::tcp::connection::accept(), pion::tcp::stream_buffer::get_connection(), get_ssl_flag(), and pion::tcp::connection::handshake_server().

void pion::tcp::stream::close ( void  )
inline
boost::system::error_code pion::tcp::stream::connect ( boost::asio::ip::tcp::endpoint &  tcp_endpoint)
inline

connects to a remote endpoint and performs SSL handshake if necessary

Parameters
tcp_endpointremote endpoint to connect to
Returns
boost::system::error_code contains error code if the connection fails
See Also
boost::asio::basic_socket_acceptor::connect()

References pion::tcp::connection::connect(), pion::tcp::stream_buffer::get_connection(), get_ssl_flag(), and pion::tcp::connection::handshake_client().

boost::system::error_code pion::tcp::stream::connect ( const boost::asio::ip::address &  remote_addr,
const unsigned int  remote_port 
)
inline

connects to a (IPv4) remote endpoint and performs SSL handshake if necessary

Parameters
remote_addrremote IP address (v4) to connect to
remote_portremote port number to connect to
Returns
boost::system::error_code contains error code if the connection fails
See Also
boost::asio::basic_socket_acceptor::connect()

References pion::tcp::connection::connect(), pion::tcp::stream_buffer::get_connection(), get_ssl_flag(), and pion::tcp::connection::handshake_client().

boost::asio::ip::address pion::tcp::stream::get_remote_ip ( void  ) const
inline
bool pion::tcp::stream::get_ssl_flag ( void  ) const
inline

returns true if the connection is encrypted using SSL

References pion::tcp::stream_buffer::get_connection(), and pion::tcp::connection::get_ssl_flag().

Referenced by accept(), and connect().

bool pion::tcp::stream::is_open ( void  ) const
inline

returns true if the connection is currently open

References pion::tcp::stream_buffer::get_connection(), and pion::tcp::connection::is_open().

stream_buffer* pion::tcp::stream::rdbuf ( void  )
inline

returns a pointer to the stream buffer in use


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