• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
  • network
kbufferedsocket.h
1 /*
2  * Copyright (C) 2003 Thiago Macieira <thiago@kde.org>
3  *
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef KBUFFEREDSOCKET_H
26 #define KBUFFEREDSOCKET_H
27 
28 #include <tqobject.h>
29 #include <tqcstring.h>
30 #include <tqvaluelist.h>
31 #include "kstreamsocket.h"
32 #include <tdelibs_export.h>
33 
34 class TDEIOBufferBase;
35 
36 namespace KNetwork {
37 
38 class TDEBufferedSocketPrivate;
58 class TDECORE_EXPORT TDEBufferedSocket: public KStreamSocket
59 {
60  Q_OBJECT
61 
62 public:
71  TDEBufferedSocket(const TQString& node = TQString::null, const TQString& service = TQString::null,
72  TQObject* parent = 0L, const char *name = 0L);
73 
77  virtual ~TDEBufferedSocket();
78 
82  virtual void setSocketDevice(TDESocketDevice* device);
83 
84 protected:
88  virtual bool setSocketOptions(int opts);
89 
90 public:
97  virtual void close();
98 
102 #ifdef USE_QT3
103  virtual TQ_LONG bytesAvailable() const;
104 #endif
105 #ifdef USE_QT4
106  virtual qint64 bytesAvailable() const;
107 #endif
108 
112  virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L);
113 
117  virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen);
118 
125  virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, TDESocketAddress& from);
126 
130  virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen);
131 
138  virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, TDESocketAddress &from);
139 
143  virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len);
144 
151  virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const TDESocketAddress& to);
152 
156  virtual void enableRead(bool enable);
157 
161  virtual void enableWrite(bool enable);
162 
166  void setInputBuffering(bool enable);
167 
171  TDEIOBufferBase* inputBuffer();
172 
176  void setOutputBuffering(bool enable);
177 
181  TDEIOBufferBase* outputBuffer();
182 
186 #ifdef USE_QT3
187  virtual TQ_ULONG bytesToWrite() const;
188 #endif
189 #ifdef USE_QT4
190  virtual qint64 bytesToWrite() const;
191 #endif
192 
199  virtual void closeNow();
200 
204  bool canReadLine() const;
205 
209  TQCString readLine();
210 
211  // KDE4: make virtual, add timeout to match the Qt4 signature
212  // and move to another class up the hierarchy
217  void waitForConnect();
218 
219 protected:
223  virtual void stateChanging(SocketState newState);
224 
225 protected slots:
229  virtual void slotReadActivity();
230 
234  virtual void slotWriteActivity();
235 
236 signals:
240  void bytesWritten(int bytes);
241 
242 private:
243  TDEBufferedSocket(const TDEBufferedSocket&);
244  TDEBufferedSocket& operator=(const TDEBufferedSocket&);
245 
246  TDEBufferedSocketPrivate *d;
247 
248 public:
249  // KDE4: remove this function
258 #ifdef USE_QT3
259  inline void reset()
260 #endif
261 #ifdef USE_QT4
262  inline bool reset()
263 #endif
264  { closeNow(); }
265 };
266 
267 } // namespace KNetwork
268 
269 #endif
KNetwork::TDESocketAddress
A generic socket address.
Definition: tdesocketaddress.h:423
KNetwork::KStreamSocket
Simple stream socket.
Definition: kstreamsocket.h:97
TDEIOBufferBase
base for I/O buffer implementation
Definition: tdeiobuffer.h:45
KNetwork::TDESocketDevice
Low-level socket functionality.
Definition: tdesocketdevice.h:50
KNetwork
A namespace to store all networking-related (socket) classes.
Definition: kbufferedsocket.h:36
KNetwork::KClientSocketBase::SocketState
SocketState
Socket states.
Definition: kclientsocketbase.h:81
KNetwork::TDEBufferedSocket
Buffered stream sockets.
Definition: kbufferedsocket.h:58

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.8
This website is maintained by Timothy Pearson.