Logo Search packages:      
Sourcecode: kmess version File versions

TcpConnectionBase Class Reference

#include <tcpconnectionbase.h>

Inheritance diagram for TcpConnectionBase:

HttpSoapConnection OfflineImService

List of all members.

Detailed Description

A base for socket handling.

This class implements a base for connection handling.

It implements the following features:

Internally, KExtendedSocket is used for compatibility with older KDE versions.

The following methods are especially useful for derived classes:

Derived classes should overwrite the following methods to implement the event handling:

Diederik van der Boor

Definition at line 63 of file tcpconnectionbase.h.

Public Member Functions

virtual void closeConnection ()
 Close the connection.
QString getRemoteIp () const
 Get the remote ip the socket is connected with.
QString getRemotePort () const
 Get the remote port the socket is connected with.
QString getSocketError () const
 Get a description of the socket error.
bool isConnected () const
 Return true if a connection is active.
bool openConnection (const QString &host, int port, bool ssl=false, bool async=true)
 Connect to a remote host.
 TcpConnectionBase (QObject *parent=0, const char *name=0)
 The constructor.
virtual ~TcpConnectionBase ()
 The destructor.

Protected Slots

virtual void slotConnectionEstablished ()=0
 Called when the connection is established.
virtual void slotConnectionFailed ()
 Called when an error occured while connecting.
virtual void slotDataReceived ()=0
 Called when data is received from the socket.

Protected Member Functions

virtual bool closeSockets ()
 Close the sockets.
int getBytesAvailable () const
 Return the number of bytes which are already received in the local buffer.
int getConnectTimeout () const
 Return the connect timeout in seconds.
int peekBlock (QByteArray *buffer, const int maxSize=0, const int offset=0)
 Peek data from the socket.
int peekBlock (char *buffer, const int size)
 Peek data from the socket.
QByteArray readAll ()
 Return all data available in the read buffer.
int readBlock (QByteArray *buffer, const int maxSize=0, const int offset=0)
 Read data from the socket.
int readBlock (char *buffer, const int size)
 Read data from the socket.
void setConnectTimeout (int seconds)
 Set the connect timeout.
void stopTimeoutDetection ()
 Stop the connection timeout detection.
bool writeBlock (const QByteArray &block)
 Write data to the socket.
bool writeBlock (const char *block, const int size)
 Write data to the socket.

Private Slots

void slotConnectionTimeout ()
 Called when timeout occured while connecting to a remote host.
void slotSocketConnected ()
 Called when the socket connected.
void slotSocketFailed (int error)
 Called when the connection could not be made.
void slotSocketReadyRead ()
 Called when new data is available to read.
void slotSocketReadyWrite ()
 Called when the socket can write new data.

Private Member Functions

bool parseBuffer (QByteArray *buffer, const int maxSize, const int bufferOffset, char **bufferStart, int *blockSize)
 Generate data/size values from a QByteArray buffer.

Private Attributes

QString connectingTo_
 The location openConnection() is connecting to, for debugging.
QTimer connectionTimer_
 The timeout handling for openConnection().
int connectTimeout_
 The connect timeout.
KMessBuffer readBuffer_
 The buffer for read data.
KExtendedSocket * socket_
 The socket over which data is sent or received.
KSSL * ssl_
 The SSL presentation wrapper.
bool timeout_
 Whether an timeout occured.

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

Generated by  Doxygen 1.6.0   Back to index