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

kdecore

  • kdecore
  • network
ksocketdevice.h
1 /* -*- C++ -*-
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 KSOCKETDEVICE_H
26 #define KSOCKETDEVICE_H
27 
28 #include <tqsocketnotifier.h>
29 #include "ksocketbase.h"
30 
31 namespace KNetwork {
32 
33 class KSocketDevice;
34 class KSocketDeviceFactoryBase;
35 
36 class KSocketDevicePrivate;
50 class KDECORE_EXPORT KSocketDevice: public KActiveSocketBase, public KPassiveSocketBase
51 {
52 public:
63  enum Capabilities
64  {
67  CanConnectString = 0x01,
68 
71  CanBindString = 0x02,
72 
75  CanNotBind = 0x04,
76 
79  CanNotListen = 0x08,
80 
84  CanMulticast = 0x10,
85 
90  CanNotUseDatagrams = 0x20
91  };
92 protected:
95  int m_sockfd;
96 
97 public:
104  explicit KSocketDevice(const KSocketBase* = 0L);
105 
112  explicit KSocketDevice(int fd);
113 
117  virtual ~KSocketDevice();
118 
122  inline int socket() const
123  { return m_sockfd; }
124 
134  virtual int capabilities() const
135  { return 0; }
136 
140  virtual bool setSocketOptions(int opts);
141 
145  virtual bool open(TQ_OpenMode mode);
146 
152  virtual void close();
153 
157  virtual void flush()
158  { }
159 
164  virtual bool create(int family, int type, int protocol);
165 
170  bool create(const KResolverEntry& address);
171 
175  virtual bool bind(const KResolverEntry& address);
176 
180  virtual bool listen(int backlog = 5); // 5 is arbitrary
181 
185  virtual bool connect(const KResolverEntry& address);
186 
191  virtual KSocketDevice* accept();
192 
196  virtual bool disconnect();
197 
201 #ifdef USE_QT3
202  virtual TQ_LONG bytesAvailable() const;
203 #endif
204 #ifdef USE_QT4
205  virtual qint64 bytesAvailable() const;
206 #endif
207 
214  virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L);
215 
219  virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen);
220 
224  virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, KSocketAddress& from);
225 
229  virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen);
230 
234  virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, KSocketAddress& from);
235 
239  virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len);
240 
244  virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const KSocketAddress& to);
245 
249  virtual KSocketAddress localAddress() const;
250 
255  virtual KSocketAddress peerAddress() const;
256 
271  virtual KSocketAddress externalAddress() const;
272 
280  TQSocketNotifier* readNotifier() const;
281 
288  TQSocketNotifier* writeNotifier() const;
289 
296  TQSocketNotifier* exceptionNotifier() const;
297 
316  virtual bool poll(bool* input, bool* output, bool* exception = 0L,
317  int timeout = -1, bool* timedout = 0L);
318 
330  bool poll(int timeout = -1, bool* timedout = 0L);
331 
332 protected:
340  KSocketDevice(bool, const KSocketBase* parent = 0L);
341 
357  virtual TQSocketNotifier* createNotifier(TQSocketNotifier::Type type) const;
358 
359 public:
370  static KSocketDevice* createDefault(KSocketBase* parent);
371 
380  static KSocketDevice* createDefault(KSocketBase* parent, int capabilities);
381 
388  static KSocketDeviceFactoryBase* setDefaultImpl(KSocketDeviceFactoryBase* factory);
389 
394  static void addNewImpl(KSocketDeviceFactoryBase* factory, int capabilities);
395 
396 private:
397  KSocketDevice(const KSocketDevice&);
398  KSocketDevice& operator=(const KSocketDevice&);
399 
400  KSocketDevicePrivate *d;
401 };
402 
407 class KSocketDeviceFactoryBase
408 {
409 public:
410  KSocketDeviceFactoryBase() {}
411  virtual ~KSocketDeviceFactoryBase() {}
412 
413  virtual KSocketDevice* create(KSocketBase*) const = 0;
414 };
415 
420 template<class Impl>
421 class KSocketDeviceFactory: public KSocketDeviceFactoryBase
422 {
423 public:
424  KSocketDeviceFactory() {}
425  virtual ~KSocketDeviceFactory() {}
426 
427  virtual KSocketDevice* create(KSocketBase* parent) const
428  { return new Impl(parent); }
429 };
430 
431 } // namespaces
432 
433 #endif

kdecore

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

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.8.1.2
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |