tdecore
kbufferedsocket.h
00001
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 <tqobject.h>
00029 #include <tqcstring.h>
00030 #include <tqvaluelist.h>
00031 #include "kstreamsocket.h"
00032 #include <tdelibs_export.h>
00033
00034 class TDEIOBufferBase;
00035
00036 namespace KNetwork {
00037
00038 class TDEBufferedSocketPrivate;
00058 class TDECORE_EXPORT TDEBufferedSocket: public KStreamSocket
00059 {
00060 Q_OBJECT
00061
00062 public:
00071 TDEBufferedSocket(const TQString& node = TQString::null, const TQString& service = TQString::null,
00072 TQObject* parent = 0L, const char *name = 0L);
00073
00077 virtual ~TDEBufferedSocket();
00078
00082 virtual void setSocketDevice(TDESocketDevice* device);
00083
00084 protected:
00088 virtual bool setSocketOptions(int opts);
00089
00090 public:
00097 virtual void close();
00098
00102 #ifdef USE_QT3
00103 virtual TQ_LONG bytesAvailable() const;
00104 #endif
00105 #ifdef USE_QT4
00106 virtual qint64 bytesAvailable() const;
00107 #endif
00108
00112 virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L);
00113
00117 virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen);
00118
00125 virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, TDESocketAddress& from);
00126
00130 virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen);
00131
00138 virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, TDESocketAddress &from);
00139
00143 virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len);
00144
00151 virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const TDESocketAddress& to);
00152
00156 virtual void enableRead(bool enable);
00157
00161 virtual void enableWrite(bool enable);
00162
00166 void setInputBuffering(bool enable);
00167
00171 TDEIOBufferBase* inputBuffer();
00172
00176 void setOutputBuffering(bool enable);
00177
00181 TDEIOBufferBase* outputBuffer();
00182
00186 #ifdef USE_QT3
00187 virtual TQ_ULONG bytesToWrite() const;
00188 #endif
00189 #ifdef USE_QT4
00190 virtual qint64 bytesToWrite() const;
00191 #endif
00192
00199 virtual void closeNow();
00200
00204 bool canReadLine() const;
00205
00209 TQCString readLine();
00210
00211
00212
00217 void waitForConnect();
00218
00219 protected:
00223 virtual void stateChanging(SocketState newState);
00224
00225 protected slots:
00229 virtual void slotReadActivity();
00230
00234 virtual void slotWriteActivity();
00235
00236 signals:
00240 void bytesWritten(int bytes);
00241
00242 private:
00243 TDEBufferedSocket(const TDEBufferedSocket&);
00244 TDEBufferedSocket& operator=(const TDEBufferedSocket&);
00245
00246 TDEBufferedSocketPrivate *d;
00247
00248 public:
00249
00258 #ifdef USE_QT3
00259 inline void reset()
00260 #endif
00261 #ifdef USE_QT4
00262 inline bool reset()
00263 #endif
00264 { closeNow(); }
00265 };
00266
00267 }
00268
00269 #endif