kbufferedsocket.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef KBUFFEREDSOCKET_H
00026 #define KBUFFEREDSOCKET_H
00027
00028 #include <qobject.h>
00029 #include <qcstring.h>
00030 #include <qvaluelist.h>
00031 #include "kstreamsocket.h"
00032 #include <kdelibs_export.h>
00033
00034 class KIOBufferBase;
00035
00036 namespace KNetwork {
00037
00038 class KBufferedSocketPrivate;
00058 class KDECORE_EXPORT KBufferedSocket: public KStreamSocket
00059 {
00060 Q_OBJECT
00061 public:
00070 KBufferedSocket(const QString& node = QString::null, const QString& service = QString::null,
00071 QObject* parent = 0L, const char *name = 0L);
00072
00076 virtual ~KBufferedSocket();
00077
00081 virtual void setSocketDevice(KSocketDevice* device);
00082
00083 protected:
00087 virtual bool setSocketOptions(int opts);
00088
00089 public:
00096 virtual void close();
00097
00101 virtual Q_LONG bytesAvailable() const;
00102
00106 virtual Q_LONG waitForMore(int msecs, bool *timeout = 0L);
00107
00111 virtual Q_LONG readBlock(char *data, Q_ULONG maxlen);
00112
00119 virtual Q_LONG readBlock(char *data, Q_ULONG maxlen, KSocketAddress& from);
00120
00124 virtual Q_LONG peekBlock(char *data, Q_ULONG maxlen);
00125
00132 virtual Q_LONG peekBlock(char *data, Q_ULONG maxlen, KSocketAddress &from);
00133
00137 virtual Q_LONG writeBlock(const char *data, Q_ULONG len);
00138
00145 virtual Q_LONG writeBlock(const char *data, Q_ULONG len, const KSocketAddress& to);
00146
00150 virtual void enableRead(bool enable);
00151
00155 virtual void enableWrite(bool enable);
00156
00160 void setInputBuffering(bool enable);
00161
00165 KIOBufferBase* inputBuffer();
00166
00170 void setOutputBuffering(bool enable);
00171
00175 KIOBufferBase* outputBuffer();
00176
00180 virtual Q_ULONG bytesToWrite() const;
00181
00188 virtual void closeNow();
00189
00193 bool canReadLine() const;
00194
00198 QCString readLine();
00199
00200
00201
00206 void waitForConnect();
00207
00208 protected:
00212 virtual void stateChanging(SocketState newState);
00213
00214 protected slots:
00218 virtual void slotReadActivity();
00219
00223 virtual void slotWriteActivity();
00224
00225 signals:
00229 void bytesWritten(int bytes);
00230
00231 private:
00232 KBufferedSocket(const KBufferedSocket&);
00233 KBufferedSocket& operator=(const KBufferedSocket&);
00234
00235 KBufferedSocketPrivate *d;
00236
00237 public:
00238
00247 inline void reset()
00248 { closeNow(); }
00249 };
00250
00251 }
00252
00253 #endif
|