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

KDECore

k3socketdevice.h

Go to the documentation of this file.
00001 /*  -*- C++ -*-
00002  *  Copyright (C) 2003,2005 Thiago Macieira <thiago@kde.org>
00003  *
00004  *
00005  *  Permission is hereby granted, free of charge, to any person obtaining
00006  *  a copy of this software and associated documentation files (the
00007  *  "Software"), to deal in the Software without restriction, including
00008  *  without limitation the rights to use, copy, modify, merge, publish,
00009  *  distribute, sublicense, and/or sell copies of the Software, and to
00010  *  permit persons to whom the Software is furnished to do so, subject to
00011  *  the following conditions:
00012  *
00013  *  The above copyright notice and this permission notice shall be included 
00014  *  in all copies or substantial portions of the Software.
00015  *
00016  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00017  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00018  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00019  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00020  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00021  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00022  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00025 #ifndef KSOCKETDEVICE_H
00026 #define KSOCKETDEVICE_H
00027 
00028 #include <QtCore/QSocketNotifier>
00029 #include "k3socketbase.h"
00030 
00031 namespace KNetwork {
00032 
00033 class KSocketDevice;
00034 class KSocketDeviceFactoryBase;
00035 
00036 class KSocketDevicePrivate;
00050 class KDECORE_EXPORT KSocketDevice: public KActiveSocketBase, public KPassiveSocketBase
00051 {
00052 public:
00063   enum Capabilities
00064     {
00067       CanConnectString = 0x01,
00068 
00071       CanBindString = 0x02,
00072 
00075       CanNotBind = 0x04,
00076 
00079       CanNotListen = 0x08,
00080 
00084       CanMulticast = 0x10,
00085 
00090       CanNotUseDatagrams = 0x20
00091     };
00092 protected:
00095   int m_sockfd;
00096 
00097 public:
00104   explicit KSocketDevice(const KSocketBase* = 0L, QObject* objparent = 0L);
00105 
00112   explicit KSocketDevice(int fd, OpenMode mode = ReadWrite);
00113 
00117   KSocketDevice(QObject* parent);
00118 
00122   virtual ~KSocketDevice();
00123 
00127   int socket() const;
00128 
00138   virtual int capabilities() const;
00139 
00143   virtual bool setSocketOptions(int opts);
00144 
00150   virtual void close();
00151 
00155   virtual bool flush();
00156 
00161   virtual bool create(int family, int type, int protocol);
00162 
00167   bool create(const KResolverEntry& address);
00168 
00172   virtual bool bind(const KResolverEntry& address);
00173 
00177   virtual bool listen(int backlog = 5); // 5 is arbitrary
00178 
00182   virtual bool connect(const KResolverEntry& address, 
00183                OpenMode mode = ReadWrite);
00184 
00189   virtual KSocketDevice* accept();
00190 
00194   virtual bool disconnect();
00195 
00199   virtual qint64 bytesAvailable() const;
00200 
00207   virtual qint64 waitForMore(int msecs, bool *timeout = 0L);
00208 
00212   virtual KSocketAddress localAddress() const;
00213 
00218   virtual KSocketAddress peerAddress() const;
00219 
00234   virtual KSocketAddress externalAddress() const;
00235 
00243   QSocketNotifier* readNotifier() const;
00244 
00251   QSocketNotifier* writeNotifier() const;
00252 
00259   QSocketNotifier* exceptionNotifier() const;
00260 
00264   virtual qint64 readData(char *data, qint64 maxlen, KSocketAddress* from = 0L);
00265 
00269   virtual qint64 peekData(char *data, qint64 maxlen, KSocketAddress* from = 0L);
00270 
00274   virtual qint64 writeData(const char *data, qint64 len, 
00275                const KSocketAddress* to = 0L);
00276 
00295   virtual bool poll(bool* input, bool* output, bool* exception = 0L,
00296             int timeout = -1, bool* timedout = 0L);
00297 
00309   bool poll(int timeout = -1, bool* timedout = 0L);
00310 
00311 protected:
00319   explicit KSocketDevice(bool, const KSocketBase* parent = 0L);
00320 
00336   virtual QSocketNotifier* createNotifier(QSocketNotifier::Type type) const;
00337 
00338 public:
00349   static KSocketDevice* createDefault(KSocketBase* parent);
00350 
00359   static KSocketDevice* createDefault(KSocketBase* parent, int capabilities);
00360 
00367   static KSocketDeviceFactoryBase* setDefaultImpl(KSocketDeviceFactoryBase* factory);
00368 
00373   static void addNewImpl(KSocketDeviceFactoryBase* factory, int capabilities);
00374 
00375 private:
00376   KSocketDevice(const KSocketDevice&);
00377   KSocketDevice& operator=(const KSocketDevice&);
00378 
00379   KSocketDevicePrivate* const d;
00380 };
00381 
00386 class KSocketDeviceFactoryBase
00387 {
00388 public:
00389   KSocketDeviceFactoryBase() {}
00390   virtual ~KSocketDeviceFactoryBase() {}
00391 
00392   virtual KSocketDevice* create(KSocketBase*) const = 0;
00393 };
00394 
00399 template<class Impl>
00400 class KSocketDeviceFactory: public KSocketDeviceFactoryBase
00401 {
00402 public:
00403   KSocketDeviceFactory() {}
00404   virtual ~KSocketDeviceFactory() {}
00405 
00410   virtual KSocketDevice* create(KSocketBase* parent) const
00411   { return new Impl(parent); }
00412 };
00413 
00414 }               // namespaces
00415 
00416 #endif

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal