• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.12
  • kdelibs
  • kdecore
  • network
k3socketdevice.h
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * Copyright (C) 2003,2005 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 KSOCKETDEVICE_H
26 #define KSOCKETDEVICE_H
27 
28 #include <QtCore/QSocketNotifier>
29 #include "k3socketbase.h"
30 
31 namespace KNetwork {
32 
33 class KSocketDevice;
34 class KSocketDeviceFactoryBase;
35 
36 class KSocketDevicePrivate;
51 class KDECORE_EXPORT_DEPRECATED KSocketDevice: public KActiveSocketBase, public KPassiveSocketBase
52 {
53 public:
64  enum Capabilities
65  {
68  CanConnectString = 0x01,
69 
72  CanBindString = 0x02,
73 
76  CanNotBind = 0x04,
77 
80  CanNotListen = 0x08,
81 
85  CanMulticast = 0x10,
86 
91  CanNotUseDatagrams = 0x20
92  };
93 protected:
96  int m_sockfd;
97 
98 public:
105  explicit KSocketDevice(const KSocketBase* = 0L, QObject* objparent = 0L);
106 
113  explicit KSocketDevice(int fd, OpenMode mode = ReadWrite);
114 
118  KSocketDevice(QObject* parent);
119 
123  virtual ~KSocketDevice();
124 
128  int socket() const;
129 
139  virtual int capabilities() const;
140 
144  virtual bool setSocketOptions(int opts);
145 
151  virtual void close();
152 
156  virtual bool flush();
157 
162  virtual bool create(int family, int type, int protocol);
163 
168  bool create(const KResolverEntry& address);
169 
173  virtual bool bind(const KResolverEntry& address);
174 
178  virtual bool listen(int backlog = 5); // 5 is arbitrary
179 
183  virtual bool connect(const KResolverEntry& address,
184  OpenMode mode = ReadWrite);
185 
190  virtual KSocketDevice* accept();
191 
195  virtual bool disconnect();
196 
200  virtual qint64 bytesAvailable() const;
201 
208  virtual qint64 waitForMore(int msecs, bool *timeout = 0L);
209 
213  virtual KSocketAddress localAddress() const;
214 
219  virtual KSocketAddress peerAddress() const;
220 
235  virtual KSocketAddress externalAddress() const;
236 
244  QSocketNotifier* readNotifier() const;
245 
252  QSocketNotifier* writeNotifier() const;
253 
260  QSocketNotifier* exceptionNotifier() const;
261 
265  virtual qint64 readData(char *data, qint64 maxlen, KSocketAddress* from = 0L);
266 
270  virtual qint64 peekData(char *data, qint64 maxlen, KSocketAddress* from = 0L);
271 
275  virtual qint64 writeData(const char *data, qint64 len,
276  const KSocketAddress* to = 0L);
277 
296  virtual bool poll(bool* input, bool* output, bool* exception = 0L,
297  int timeout = -1, bool* timedout = 0L);
298 
310  bool poll(int timeout = -1, bool* timedout = 0L);
311 
312 protected:
320  explicit KSocketDevice(bool, const KSocketBase* parent = 0L);
321 
337  virtual QSocketNotifier* createNotifier(QSocketNotifier::Type type) const;
338 
339 public:
350  static KSocketDevice* createDefault(KSocketBase* parent);
351 
360  static KSocketDevice* createDefault(KSocketBase* parent, int capabilities);
361 
368  static KSocketDeviceFactoryBase* setDefaultImpl(KSocketDeviceFactoryBase* factory);
369 
374  static void addNewImpl(KSocketDeviceFactoryBase* factory, int capabilities);
375 
376 private:
377  KSocketDevice(const KSocketDevice&);
378  KSocketDevice& operator=(const KSocketDevice&);
379 
380  KSocketDevicePrivate* const d;
381 };
382 
387 class KSocketDeviceFactoryBase
388 {
389 public:
390  KSocketDeviceFactoryBase() {}
391  virtual ~KSocketDeviceFactoryBase() {}
392 
393  virtual KSocketDevice* create(KSocketBase*) const = 0;
394 };
395 
400 template<class Impl>
401 class KSocketDeviceFactory: public KSocketDeviceFactoryBase
402 {
403 public:
404  KSocketDeviceFactory() {}
405  virtual ~KSocketDeviceFactory() {}
406 
411  virtual KSocketDevice* create(KSocketBase* parent) const
412  { return new Impl(parent); }
413 };
414 
415 } // namespaces
416 
417 #endif
qint64
KFileSystemType::Type
Type
Definition: kfilesystemtype_p.h:28
KNetwork::KActiveSocketBase
Abstract class for active sockets.
Definition: k3socketbase.h:461
timeout
int timeout
Definition: kkernel_mac.cpp:46
KNetwork::KResolverEntry
One resolution entry.
Definition: k3resolver.h:68
KSocketFactory::listen
QTcpServer * listen(const QString &protocol, const QHostAddress &address=QHostAddress::Any, quint16 port=0, QObject *parent=0)
Opens a TCP/IP socket for listening protocol protocol, binding only at address address.
Definition: ksocketfactory.cpp:115
KNetwork::KSocketAddress
A generic socket address.
Definition: k3socketaddress.h:414
QObject
KNetwork::KSocketDeviceFactoryBase::KSocketDeviceFactoryBase
KSocketDeviceFactoryBase()
Definition: k3socketdevice.h:390
KNetwork::KSocketDeviceFactoryBase
Definition: k3socketdevice.h:387
KNetwork::KSocketDeviceFactory
This class provides functionality for creating and registering socket implementations.
Definition: k3socketdevice.h:401
KNetwork::KSocketDeviceFactoryBase::create
virtual KSocketDevice * create(KSocketBase *) const =0
KNetwork::KSocketDeviceFactory::KSocketDeviceFactory
KSocketDeviceFactory()
Definition: k3socketdevice.h:404
k3socketbase.h
KNetwork::KSocketDevice::m_sockfd
int m_sockfd
The socket file descriptor.
Definition: k3socketdevice.h:96
output
void output(QList< Action > actions, QHash< QString, QString > domain)
Definition: fake/kauth-policy-gen-polkit.cpp:41
KNetwork::KSocketDeviceFactoryBase::~KSocketDeviceFactoryBase
virtual ~KSocketDeviceFactoryBase()
Definition: k3socketdevice.h:391
KNetwork::KSocketDevice::Capabilities
Capabilities
Capabilities for the socket implementation.
Definition: k3socketdevice.h:64
KNetwork::KSocketDeviceFactory::create
virtual KSocketDevice * create(KSocketBase *parent) const
Create the socket implementation.
Definition: k3socketdevice.h:411
KNetwork::KSocketDevice
Low-level socket functionality.
Definition: k3socketdevice.h:51
KNetwork::KSocketDeviceFactory::~KSocketDeviceFactory
virtual ~KSocketDeviceFactory()
Definition: k3socketdevice.h:405
KNetwork::KPassiveSocketBase
Abstract base class for passive sockets.
Definition: k3socketbase.h:774
KNetwork::KSocketBase
Basic socket functionality.
Definition: k3socketbase.h:85
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:07 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal