gloox  1.0
Public Member Functions | List of all members
ConnectionTCPBase Class Reference

#include <connectiontcpbase.h>

Inheritance diagram for ConnectionTCPBase:
Inheritance graph
[legend]

Public Member Functions

 ConnectionTCPBase (const LogSink &logInstance, const std::string &server, int port=-1)
 ConnectionTCPBase (ConnectionDataHandler *cdh, const LogSink &logInstance, const std::string &server, int port=-1)
virtual ~ConnectionTCPBase ()
virtual bool send (const std::string &data)
virtual ConnectionError receive ()
virtual void disconnect ()
virtual void cleanup ()
virtual void getStatistics (long int &totalIn, long int &totalOut)
int socket () const
void setSocket (int socket)
virtual int localPort () const
virtual const std::string localInterface () const
- Public Member Functions inherited from ConnectionBase
 ConnectionBase (ConnectionDataHandler *cdh)
virtual ~ConnectionBase ()
virtual ConnectionError connect ()=0
virtual ConnectionError recv (int timeout=-1)=0
ConnectionState state () const
void registerConnectionDataHandler (ConnectionDataHandler *cdh)
void setServer (const std::string &server, int port=-1)
const std::string & server () const
int port () const
virtual ConnectionBasenewInstance () const =0

Additional Inherited Members

- Protected Attributes inherited from ConnectionBase
ConnectionDataHandlerm_handler
ConnectionState m_state
std::string m_server
int m_port

Detailed Description

This is a base class for a simple TCP connection.

You should not need to use this class directly.

Author
Jakob Schroeter js@ca.nosp@m.maya.nosp@m..net
Since
0.9

Definition at line 40 of file connectiontcpbase.h.

Constructor & Destructor Documentation

ConnectionTCPBase ( const LogSink logInstance,
const std::string &  server,
int  port = -1 
)

Constructs a new ConnectionTCPBase object.

Parameters
logInstanceThe log target. Obtain it from ClientBase::logInstance().
serverA server to connect to.
portThe port to connect to. The default of -1 means that XMPP SRV records will be used to find out about the actual host:port.
Note
To properly use this object, you have to set a ConnectionDataHandler using registerConnectionDataHandler(). This is not necessary if this object is part of a 'connection chain', e.g. with ConnectionHTTPProxy.

Definition at line 47 of file connectiontcpbase.cpp.

ConnectionTCPBase ( ConnectionDataHandler cdh,
const LogSink logInstance,
const std::string &  server,
int  port = -1 
)

Constructs a new ConnectionTCPBase object.

Parameters
cdhAn ConnectionDataHandler-derived object that will handle incoming data.
logInstanceThe log target. Obtain it from ClientBase::logInstance().
serverA server to connect to.
portThe port to connect to. The default of -1 means that SRV records will be used to find out about the actual host:port.

Definition at line 56 of file connectiontcpbase.cpp.

~ConnectionTCPBase ( )
virtual

Virtual destructor

Definition at line 73 of file connectiontcpbase.cpp.

Member Function Documentation

void cleanup ( )
virtual

This function is called after a disconnect to clean up internal state. It is also called by ConnectionBase's destructor.

Reimplemented from ConnectionBase.

Definition at line 149 of file connectiontcpbase.cpp.

void disconnect ( )
virtual

Disconnects an established connection. NOOP if no active connection exists.

Implements ConnectionBase.

Definition at line 80 of file connectiontcpbase.cpp.

void getStatistics ( long int &  totalIn,
long int &  totalOut 
)
virtual

Returns current connection statistics.

Parameters
totalInThe total number of bytes received.
totalOutThe total number of bytes sent.

Implements ConnectionBase.

Definition at line 143 of file connectiontcpbase.cpp.

const std::string localInterface ( ) const
virtual

Returns the locally bound IP address.

Returns
The locally bound IP address.

Reimplemented from ConnectionBase.

Definition at line 185 of file connectiontcpbase.cpp.

int localPort ( ) const
virtual

Returns the local port.

Returns
The local port.

Reimplemented from ConnectionBase.

Definition at line 175 of file connectiontcpbase.cpp.

ConnectionError receive ( )
virtual

Use this function to put the connection into 'receive mode', i.e. this function returns only when the connection is terminated.

Returns
Returns a value indicating the disconnection reason.

Implements ConnectionBase.

Definition at line 106 of file connectiontcpbase.cpp.

bool send ( const std::string &  data)
virtual

Use this function to send a string of data over the wire. The function returns only after all data has been sent.

Parameters
dataThe data to send.
Returns
True if the data has been sent (no guarantee of receipt), false in case of an error.

Implements ConnectionBase.

Definition at line 117 of file connectiontcpbase.cpp.

void setSocket ( int  socket)
inline

This function allows to set an existing socket with an established connection to use in this connection. You will still need to call connect() in order to negotiate the XMPP stream. You should not set a new socket after having called connect().

Parameters
socketThe existing socket.

Definition at line 99 of file connectiontcpbase.h.

int socket ( ) const
inline

Gives access to the raw socket of this connection. Use it wisely. You can select()/poll() it and use ConnectionTCPBase::recv( -1 ) to fetch the data.

Returns
The socket of the active connection, or -1 if no connection is established.

Definition at line 91 of file connectiontcpbase.h.


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