Public Member Functions | Protected Member Functions | Protected Attributes

GridClientConnection Class Reference

#include <gridclientconnection.hpp>

Inheritance diagram for GridClientConnection:
GridClientHttpConnection GridClientTcpConnection GridClientRawSyncTcpConnection GridClientSyncTcpConnection GridClientAsyncTcpConnection

List of all members.

Public Member Functions

 GridClientConnection ()
 GridClientConnection (boost::shared_ptr< boost::asio::ssl::context > ctx)
virtual ~GridClientConnection ()
boost::asio::io_service & getIoService ()
boost::asio::ip::tcp::socket & getSocket ()
const
boost::asio::ip::tcp::socket & 
getSocket () const
virtual void close ()
virtual bool isOpen () const
virtual bool isConnected (const std::string &pHost, int pPort)
void setConnectionTimeout (unsigned int pConnTimeout)
void setReadTimeout (unsigned int pReadTimeout)
void setWriteTimeout (unsigned int pWriteTimeout)
void setSslContext (boost::shared_ptr< boost::asio::ssl::context > ctx)
virtual void sendPing ()=0
virtual std::string toString () const

Protected Member Functions

virtual bool verifyCertificate (bool preverified, boost::asio::ssl::verify_context &ctx)
bool isSslMode () const
void resetSocket ()

Protected Attributes

std::string host
int port
boost::asio::io_service ioSrvc
boost::shared_ptr
< boost::asio::ip::tcp::socket > 
sock
boost::shared_ptr
< boost::asio::ssl::stream
< boost::asio::ip::tcp::socket > > 
sslSock
boost::shared_ptr
< boost::asio::ssl::context > 
sslCtx
std::string sessToken
unsigned int connTimeout
unsigned int readTimeout
unsigned int writeTimeout
boost::mutex mux_
TGridAtomicBool closed

Detailed Description

Generic connection class. Current implementations are TCP and HTTP connections.


Constructor & Destructor Documentation

GridClientConnection::GridClientConnection (  ) 

Public constructor.

Parameters:
pPool Shared pointer to a connection pool.
GridClientConnection::GridClientConnection ( boost::shared_ptr< boost::asio::ssl::context >  ctx  ) 

Public constructor.

Parameters:
pPool Shared pointer to a connection pool.
ctx Boost SSL context.
GridClientConnection::~GridClientConnection (  )  [virtual]

Destructor.

Connection destructor.


Member Function Documentation

void GridClientConnection::close (  )  [virtual]

Connection close.

Closes the connection.

Reimplemented in GridClientRawSyncTcpConnection.

asio::io_service & GridClientConnection::getIoService (  ) 

Getter method for Boost IO service.

Returns:
Boost IO service currently used.

Returns an IO service for this connection.

Returns:
Boost IO service.
asio::ip::tcp::socket & GridClientConnection::getSocket (  ) 

Getter method for Boost socket.

Returns:
Boost socket associated with this connection.

Returns an underlying socket for the connection - works both for SSL and non-SSL connections.

Returns:
Boost socket.
const asio::ip::tcp::socket & GridClientConnection::getSocket (  )  const

Getter method for Boost socket - constant version.

Returns:
Boost socket associated with this connection.

Returns an underlying socket for the connection - works both for SSL and non-SSL connections - const version.

Returns:
Unmodifiable Boost socket.
virtual bool GridClientConnection::isConnected ( const std::string &  pHost,
int  pPort 
) [inline, virtual]

Test if this connection is really connected.

Parameters:
pHost Host it should be connected to.
pPort Port it should be connected to.
Returns:
true if it is connected, false otherwise.
virtual bool GridClientConnection::isOpen (  )  const [inline, virtual]

Test the state of the connection.

Returns:
true if it is open, false otherwise.
bool GridClientConnection::isSslMode (  )  const [inline, protected]

Tests if this socket is SSL-based or plain.

Returns:
true if this is a SSL socket, false otherwise.
void GridClientConnection::resetSocket (  )  [protected]

Resets the socket state.

virtual void GridClientConnection::sendPing (  )  [pure virtual]

Sends a ping packet to the peer.

Implemented in GridClientHttpConnection, GridClientSyncTcpConnection, and GridClientRawSyncTcpConnection.

void GridClientConnection::setConnectionTimeout ( unsigned int  pConnTimeout  )  [inline]

Sets a new value for the connection timeout associated with this connection.

Parameters:
pConnTimeout New value for connection timeout.
void GridClientConnection::setReadTimeout ( unsigned int  pReadTimeout  )  [inline]

Sets a new value for the connection timeout associated with this connection.

Parameters:
pConnTimeout New value for connection timeout.
void GridClientConnection::setSslContext ( boost::shared_ptr< boost::asio::ssl::context >  ctx  )  [inline]

Sets a new value for the connection timeout associated with this connection.

Parameters:
pConnTimeout New value for connection timeout.
void GridClientConnection::setWriteTimeout ( unsigned int  pWriteTimeout  )  [inline]

Sets a new value for the connection timeout associated with this connection.

Parameters:
pConnTimeout New value for connection timeout.
virtual std::string GridClientConnection::toString (  )  const [inline, virtual]

Returns a string representation of this connection.

virtual bool GridClientConnection::verifyCertificate ( bool  preverified,
boost::asio::ssl::verify_context &  ctx 
) [protected, virtual]

Verifies certificate. Returns true to follow calling conventions. Throws exception in case of problems.

Returns:
true.

Member Data Documentation

TGridAtomicBool GridClientConnection::closed [protected]

Closed flag.

unsigned int GridClientConnection::connTimeout [protected]

Connection timeout.

std::string GridClientConnection::host [protected]

Host associated with this connection.

boost::asio::io_service GridClientConnection::ioSrvc [protected]

Boost IO service.

boost::mutex GridClientConnection::mux_ [mutable, protected]

Synchronization for the underlying socket.

int GridClientConnection::port [protected]

Port associated with this connection.

unsigned int GridClientConnection::readTimeout [protected]

Read timeout.

std::string GridClientConnection::sessToken [protected]

Session token associated with this connection.

boost::shared_ptr<boost::asio::ip::tcp::socket> GridClientConnection::sock [protected]

Boost socket.

boost::shared_ptr<boost::asio::ssl::context> GridClientConnection::sslCtx [protected]

Boost SSL context.

boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket> > GridClientConnection::sslSock [protected]

Boost SSL socket.

unsigned int GridClientConnection::writeTimeout [protected]

Write timeout.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends