kbufferedsocket.h
/* -*- C++ -*-
* Copyright (C) 2003 Thiago Macieira <thiago@kde.org>
*
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef KBUFFEREDSOCKET_H
#define KBUFFEREDSOCKET_H
#include <qobject.h>
#include <qcstring.h>
#include <qvaluelist.h>
#include "kstreamsocket.h"
#include <kdelibs_export.h>
class KIOBufferBase;
namespace KNetwork {
class KBufferedSocketPrivate;
class KDECORE_EXPORT KBufferedSocket: public KStreamSocket
{
Q_OBJECT
public:
KBufferedSocket(const QString& node = QString::null, const QString& service = QString::null,
QObject* parent = 0L, const char *name = 0L);
virtual ~KBufferedSocket();
virtual void setSocketDevice(KSocketDevice* device);
protected:
virtual bool setSocketOptions(int opts);
public:
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);
KIOBufferBase* inputBuffer();
void setOutputBuffering(bool enable);
KIOBufferBase* outputBuffer();
virtual Q_ULONG bytesToWrite() const;
virtual void closeNow();
bool canReadLine() const;
QCString readLine();
// KDE4: make virtual, add timeout to match the Qt4 signature
// and move to another class up the hierarchy
void waitForConnect();
protected:
virtual void stateChanging(SocketState newState);
protected slots:
virtual void slotReadActivity();
virtual void slotWriteActivity();
signals:
void bytesWritten(int bytes);
private:
KBufferedSocket(const KBufferedSocket&);
KBufferedSocket& operator=(const KBufferedSocket&);
KBufferedSocketPrivate *d;
public:
// KDE4: remove this function
inline void reset()
{ closeNow(); }
};
} // namespace KNetwork
#endif
KNetwork::KStreamSocket
Simple stream socket.
Definition: kstreamsocket.h:97
KNetwork::KSocketAddress
A generic socket address.
Definition: ksocketaddress.h:423
KNetwork::KClientSocketBase::SocketState
SocketState
Socket states.
Definition: kclientsocketbase.h:71
KNetwork::KBufferedSocket
Buffered stream sockets.
Definition: kbufferedsocket.h:58
KIOBufferBase
base for I/O buffer implementation
Definition: kiobuffer.h:45
KNetwork::KBufferedSocket::reset
void reset()
Definition: kbufferedsocket.h:247
KNetwork::KSocketDevice
Low-level socket functionality.
Definition: ksocketdevice.h:50

KDE Home | KDE Accessibility Home | Description of Access Keys