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

tdecore

  • tdecore
  • network
kclientsocketbase.h
1 /*
2  * Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
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 KCLIENTSOCKETBASE_H
26 #define KCLIENTSOCKETBASE_H
27 
28 #include <tqobject.h>
29 #include <tqstring.h>
30 
31 #include "tdesocketbase.h"
32 #include "kresolver.h"
33 #include <tdelibs_export.h>
34 
35 #ifdef Q_MOC_RUN
36 #define USE_QT4
37 #endif // Q_MOC_RUN
38 
39 namespace KNetwork {
40 
41 class KClientSocketBasePrivate;
53 class TDECORE_EXPORT KClientSocketBase :
54 #ifdef USE_QT4
55 #else // USE_QT4
56 public TQObject,
57 #endif // USE_QT4
58 public KActiveSocketBase
59 {
60  Q_OBJECT
61 
62 
63 public:
81  enum SocketState
82  {
83  Idle,
84  HostLookup,
85  HostFound,
86  Bound,
87  Connecting,
88  Open,
89  Closing,
90 
91  Unconnected = Bound,
92  Connected = Open,
93  Connection = Open
94  };
95 
96 public:
103  KClientSocketBase(TQObject* parent, const char *name);
104 
108  virtual ~KClientSocketBase();
109 
114  SocketState state() const;
115 
116 protected:
120  virtual bool setSocketOptions(int opts);
121 
122 public:
131  KResolver& peerResolver() const;
132 
136  const KResolverResults& peerResults() const;
137 
146  KResolver& localResolver() const;
147 
151  const KResolverResults& localResults() const;
152 
167  void setResolutionEnabled(bool enable);
168 
175  void setFamily(int families);
176 
194  virtual bool lookup();
195 
215  virtual bool bind(const TQString& node = TQString::null,
216  const TQString& service = TQString::null) = 0;
217 
226  virtual bool bind(const KResolverEntry& address);
227 
256  virtual bool connect(const TQString& node = TQString::null,
257  const TQString& service = TQString::null) = 0;
258 
263  virtual bool connect(const KResolverEntry& address);
264 
270  inline void connectToHost(const TQString& host, TQ_UINT16 port)
271  { connect(host, TQString::number(port)); }
272 
277  virtual bool disconnect();
278 
284  virtual inline bool open(TQ_OpenMode)
285  { return connect(); }
286 
293  virtual void close();
294 
298  virtual void flush()
299  { }
300 
305 #ifdef USE_QT3
306  virtual TQ_LONG bytesAvailable() const;
307 #endif
308 #ifdef USE_QT4
309  virtual qint64 bytesAvailable() const;
310 #endif
311 
315  virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L);
316 
320  virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen);
321 
326  virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, TDESocketAddress& from);
327 
331  virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen);
332 
337  virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, TDESocketAddress &from);
338 
342  virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len);
343 
348  virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const TDESocketAddress& to);
349 
353  virtual TDESocketAddress localAddress() const;
354 
358  virtual TDESocketAddress peerAddress() const;
359 
363  bool emitsReadyRead() const;
364 
371  virtual void enableRead(bool enable);
372 
376  bool emitsReadyWrite() const;
377 
384  virtual void enableWrite(bool enable);
385 
386 protected slots:
387  // protected slots
388 
398  virtual void slotReadActivity();
399 
409  virtual void slotWriteActivity();
410 
411 private slots:
412  void lookupFinishedSlot();
413 
414 signals:
423  void stateChanged(int newstate);
424 
430  void gotError(int code);
431 
435  void hostFound();
436 
443  void bound(const KResolverEntry& local);
444 
460  void aboutToConnect(const KResolverEntry& remote, bool& skip);
461 
468  void connected(const KResolverEntry& remote);
469 
474  void closed();
475 
484  void readyRead();
485 
497  void readyWrite();
498 
499 protected:
504  void setState(SocketState state);
505 
515  virtual void stateChanging(SocketState newState);
516 
521  void copyError();
522 
523 private:
524  KClientSocketBase(const KClientSocketBase&);
525  KClientSocketBase& operator=(const KClientSocketBase&);
526 
527  KClientSocketBasePrivate *d;
528 };
529 
530 } // namespace KNetwork
531 
532 #endif
KNetwork::TDESocketAddress
A generic socket address.
Definition: tdesocketaddress.h:423
KNetwork::KActiveSocketBase
Abstract class for active sockets.
Definition: tdesocketbase.h:443
KNetwork::KResolverEntry
One resolution entry.
Definition: kresolver.h:66
KNetwork::KClientSocketBase::flush
virtual void flush()
This call is not supported on sockets.
Definition: kclientsocketbase.h:298
KNetwork::KResolver
Name and service resolution class.
Definition: kresolver.h:295
KNetwork::KClientSocketBase::connectToHost
void connectToHost(const TQString &host, TQ_UINT16 port)
Definition: kclientsocketbase.h:270
KNetwork::KResolverResults
Name and service resolution results.
Definition: kresolver.h:197
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::KClientSocketBase::open
virtual bool open(TQ_OpenMode)
Opens the socket.
Definition: kclientsocketbase.h:284
KNetwork::KClientSocketBase
Abstract client socket class.
Definition: kclientsocketbase.h:53

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.