kdecore Library API Documentation

KNetwork::KBufferedSocket Class Reference

Buffered stream sockets. More...

#include <kbufferedsocket.h>

Inheritance diagram for KNetwork::KBufferedSocket:

KNetwork::KStreamSocket KNetwork::KClientSocketBase QObject KNetwork::KActiveSocketBase QIODevice KNetwork::KSocketBase List of all members.

Signals

void bytesWritten (int bytes)

Public Member Functions

 KBufferedSocket (const QString &host=QString::null, const QString &service=QString::null, QObject *parent=0L, const char *name=0L)
virtual ~KBufferedSocket ()
virtual void setSocketDevice (KSocketDevice *device)
virtual void close ()
virtual Q_LONG bytesAvailable () const
virtual Q_LONG waitForMore (int msecs, bool *timeout=0L)
virtual Q_LONG readBlock (char *data, Q_ULONG maxlen)
virtual Q_LONG readBlock (char *data, Q_ULONG maxlen, KSocketAddress &from)
virtual Q_LONG peekBlock (char *data, Q_ULONG maxlen)
virtual Q_LONG peekBlock (char *data, Q_ULONG maxlen, KSocketAddress &from)
virtual Q_LONG writeBlock (const char *data, Q_ULONG len)
virtual Q_LONG writeBlock (const char *data, Q_ULONG len, const KSocketAddress &to)
virtual void enableRead (bool enable)
virtual void enableWrite (bool enable)
void setInputBuffering (bool enable)
KIOBufferBaseinputBuffer ()
void setOutputBuffering (bool enable)
KIOBufferBaseoutputBuffer ()
virtual Q_ULONG bytesToWrite () const
virtual void closeNow ()
bool canReadLine () const
QCString readLine ()
void reset ()

Protected Slots

virtual void slotReadActivity ()
virtual void slotWriteActivity ()

Protected Member Functions

virtual bool setSocketOptions (int opts)
virtual void stateChanging (SocketState newState)

Detailed Description

Buffered stream sockets.

This class allows the user to create and operate buffered stream sockets such as those used in most Internet connections. This class is also the one that resembles the most to the old QSocket implementation.

Author:
Thiago Macieira <thiago.macieira@kdemail.net>

Definition at line 47 of file kbufferedsocket.h.


Constructor & Destructor Documentation

KBufferedSocket::KBufferedSocket const QString host = QString::null,
const QString service = QString::null,
QObject parent = 0L,
const char *  name = 0L
 

Default constructor.

Parameters:
node destination host
service destination service to connect to

Definition at line 50 of file kbufferedsocket.cpp.

References KNetwork::KSocketBase::setBlocking(), setInputBuffering(), and setOutputBuffering().

KBufferedSocket::~KBufferedSocket  )  [virtual]
 

Destructor.

Definition at line 60 of file kbufferedsocket.cpp.

References closeNow().


Member Function Documentation

void KBufferedSocket::setSocketDevice KSocketDevice device  )  [virtual]
 

Be sure to catch new devices.

Reimplemented from KNetwork::KSocketBase.

Definition at line 68 of file kbufferedsocket.cpp.

References KNetwork::KSocketBase::setBlocking().

bool KBufferedSocket::setSocketOptions int  opts  )  [protected, virtual]
 

Buffered sockets can only operate in blocking mode.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 74 of file kbufferedsocket.cpp.

void KBufferedSocket::close  )  [virtual]
 

Closes the socket for new data, but allow data that had been buffered for output with writeBlock to be still be written.

See also:
closeNow

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 83 of file kbufferedsocket.cpp.

References closeNow(), KNetwork::KSocketDevice::readNotifier(), KNetwork::KClientSocketBase::setState(), KNetwork::KSocketBase::socketDevice(), and KNetwork::KClientSocketBase::stateChanged().

Q_LONG KBufferedSocket::bytesAvailable  )  const [virtual]
 

Make use of the buffers.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 97 of file kbufferedsocket.cpp.

Referenced by waitForMore().

Q_LONG KBufferedSocket::waitForMore int  msecs,
bool *  timeout = 0L
[virtual]
 

Make use of buffers.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 105 of file kbufferedsocket.cpp.

References bytesAvailable(), KNetwork::KActiveSocketBase::resetError(), and slotReadActivity().

Q_LONG KBufferedSocket::readBlock char *  data,
Q_ULONG  maxlen
[virtual]
 

Reads data from the socket.

Make use of buffers.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 117 of file kbufferedsocket.cpp.

References KNetwork::KClientSocketBase::gotError(), KNetwork::KActiveSocketBase::resetError(), and KNetwork::KActiveSocketBase::setError().

Referenced by readBlock().

Q_LONG KBufferedSocket::readBlock char *  data,
Q_ULONG  maxlen,
KSocketAddress from
[virtual]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Reads data from a socket.

The from parameter is always set to peerAddress()

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 133 of file kbufferedsocket.cpp.

References KNetwork::KClientSocketBase::peerAddress(), and readBlock().

Q_LONG KBufferedSocket::peekBlock char *  data,
Q_ULONG  maxlen
[virtual]
 

Peeks data from the socket.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 139 of file kbufferedsocket.cpp.

References KNetwork::KClientSocketBase::gotError(), KNetwork::KActiveSocketBase::resetError(), and KNetwork::KActiveSocketBase::setError().

Referenced by peekBlock().

Q_LONG KBufferedSocket::peekBlock char *  data,
Q_ULONG  maxlen,
KSocketAddress from
[virtual]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Peeks data from the socket.

The from parameter is always set to peerAddress()

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 155 of file kbufferedsocket.cpp.

References peekBlock(), and KNetwork::KClientSocketBase::peerAddress().

Q_LONG KBufferedSocket::writeBlock const char *  data,
Q_ULONG  len
[virtual]
 

Writes data to the socket.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 161 of file kbufferedsocket.cpp.

References KNetwork::KClientSocketBase::gotError(), KNetwork::KActiveSocketBase::resetError(), KNetwork::KActiveSocketBase::setError(), KNetwork::KSocketBase::socketDevice(), KNetwork::KClientSocketBase::state(), and KNetwork::KSocketDevice::writeNotifier().

Referenced by writeBlock().

Q_LONG KBufferedSocket::writeBlock const char *  data,
Q_ULONG  len,
const KSocketAddress to
[virtual]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Writes data to the socket.

The to parameter is discarded.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 191 of file kbufferedsocket.cpp.

References writeBlock().

void KBufferedSocket::enableRead bool  enable  )  [virtual]
 

Catch changes.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 198 of file kbufferedsocket.cpp.

References KNetwork::KSocketDevice::readNotifier(), slotReadActivity(), KNetwork::KSocketBase::socketDevice(), and KNetwork::KClientSocketBase::state().

Referenced by stateChanging().

void KBufferedSocket::enableWrite bool  enable  )  [virtual]
 

Catch changes.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 215 of file kbufferedsocket.cpp.

References KNetwork::KSocketBase::socketDevice(), and KNetwork::KSocketDevice::writeNotifier().

Referenced by stateChanging().

void KBufferedSocket::setInputBuffering bool  enable  ) 
 

Sets the use of input buffering.

Definition at line 245 of file kbufferedsocket.cpp.

References KNetwork::KSocketBase::mutex().

Referenced by KBufferedSocket().

KIOBufferBase * KBufferedSocket::inputBuffer  ) 
 

Retrieves the input buffer object.

Definition at line 259 of file kbufferedsocket.cpp.

void KBufferedSocket::setOutputBuffering bool  enable  ) 
 

Sets the use of output buffering.

Definition at line 264 of file kbufferedsocket.cpp.

References KNetwork::KSocketBase::mutex().

Referenced by KBufferedSocket().

KIOBufferBase * KBufferedSocket::outputBuffer  ) 
 

Retrieves the output buffer object.

Definition at line 278 of file kbufferedsocket.cpp.

Q_ULONG KBufferedSocket::bytesToWrite  )  const [virtual]
 

Returns the length of the output buffer.

Definition at line 283 of file kbufferedsocket.cpp.

void KBufferedSocket::closeNow  )  [virtual]
 

Closes the socket and discards any output data that had been buffered with writeBlock but that had not yet been written.

See also:
close

Definition at line 291 of file kbufferedsocket.cpp.

Referenced by close(), slotReadActivity(), slotWriteActivity(), and ~KBufferedSocket().

bool KBufferedSocket::canReadLine  )  const
 

Returns true if a line can be read with readLine.

Definition at line 296 of file kbufferedsocket.cpp.

QCString KBufferedSocket::readLine  ) 
 

Reads a line of data from the socket buffers.

Definition at line 304 of file kbufferedsocket.cpp.

void KBufferedSocket::stateChanging SocketState  newState  )  [protected, virtual]
 

Catch connection to clear the buffers.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 227 of file kbufferedsocket.cpp.

References KNetwork::KClientSocketBase::emitsReadyRead(), KNetwork::KClientSocketBase::emitsReadyWrite(), enableRead(), and enableWrite().

void KBufferedSocket::slotReadActivity  )  [protected, virtual, slot]
 

Slot called when there's read activity.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 309 of file kbufferedsocket.cpp.

References closeNow(), KNetwork::KClientSocketBase::copyError(), KNetwork::KClientSocketBase::emitsReadyRead(), KNetwork::KSocketBase::error(), KNetwork::KSocketBase::mutex(), KNetwork::KClientSocketBase::readyRead(), KNetwork::KActiveSocketBase::resetError(), KNetwork::KSocketBase::socketDevice(), and KNetwork::KClientSocketBase::state().

Referenced by enableRead(), and waitForMore().

void KBufferedSocket::slotWriteActivity  )  [protected, virtual, slot]
 

Slot called when there's write activity.

Reimplemented from KNetwork::KClientSocketBase.

Definition at line 354 of file kbufferedsocket.cpp.

References bytesWritten(), closeNow(), KNetwork::KClientSocketBase::copyError(), KNetwork::KSocketBase::error(), KNetwork::KSocketBase::mutex(), KNetwork::KActiveSocketBase::resetError(), KNetwork::KSocketBase::socketDevice(), KNetwork::KClientSocketBase::state(), and KNetwork::KSocketDevice::writeNotifier().

void KNetwork::KBufferedSocket::bytesWritten int  bytes  )  [signal]
 

This signal is emitted whenever data is written.

Referenced by slotWriteActivity().

void KNetwork::KBufferedSocket::reset  )  [inline]
 

Deprecated:
Closes the socket.
This function is provided to ease porting from KExtendedSocket, which required a call to reset() in order to be able to connect again using the same device. This is not necessary in KBufferedSocket any more.

Definition at line 226 of file kbufferedsocket.h.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdecore Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Nov 27 13:41:54 2004 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003