ConnectionTCPBase Class Reference

This is a base class for a simple TCP connection. More...

#include <connectiontcpbase.h>

Inherits gloox::ConnectionBase.

Inherited by ConnectionTCPClient, and ConnectionTCPServer.

List of all members.

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

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@camaya.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:
logInstance The log target. Obtain it from ClientBase::logInstance().
server A server to connect to.
port The 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 24 of file connectiontcpbase.cpp.

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

Constructs a new ConnectionTCPBase object.

Parameters:
cdh An ConnectionDataHandler-derived object that will handle incoming data.
logInstance The log target. Obtain it from ClientBase::logInstance().
server A server to connect to.
port The 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 33 of file connectiontcpbase.cpp.

~ConnectionTCPBase (  )  [virtual]

Virtual destructor

Definition at line 50 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 126 of file connectiontcpbase.cpp.

void disconnect (  )  [virtual]

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

Implements ConnectionBase.

Definition at line 57 of file connectiontcpbase.cpp.

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

Returns current connection statistics.

Parameters:
totalIn The total number of bytes received.
totalOut The total number of bytes sent.

Implements ConnectionBase.

Definition at line 120 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 162 of file connectiontcpbase.cpp.

int localPort (  )  const [virtual]

Returns the local port.

Returns:
The local port.

Reimplemented from ConnectionBase.

Definition at line 152 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 83 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:
data The 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 94 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:
socket The 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:
Generated on Tue Jun 8 23:37:56 2010 for gloox by  doxygen 1.6.3