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

#include <connectiontcpbase.h>

Inheritance diagram for ConnectionTCPBase:
Inheritance graph
[legend]
Collaboration diagram for ConnectionTCPBase:
Collaboration 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 (int &totalIn, int &totalOut)
int socket () const
void setSocket (int socket)
- 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
virtual ConnectionBasenewInstance () const =0

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 37 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 48 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 57 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 151 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 ( int &  totalIn,
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 145 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 104 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 115 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 96 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 88 of file connectiontcpbase.h.


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