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

KDECore

k3clientsocketbase.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 KCLIENTSOCKETBASE_H
00026 #define KCLIENTSOCKETBASE_H
00027 
00028 #include <QtCore/QObject>
00029 #include <QtCore/QString>
00030 
00031 #include <kdecore_export.h>
00032 #include "k3socketbase.h"
00033 #include "k3resolver.h"
00034 
00035 namespace KNetwork {
00036 
00037 class KClientSocketBasePrivate;
00049 class KDECORE_EXPORT KClientSocketBase : public KActiveSocketBase
00050 {
00051   Q_OBJECT
00052 
00053 public:
00071   enum SocketState
00072   {
00073     Idle,
00074     HostLookup,
00075     HostFound,
00076     Bound,
00077     Connecting,
00078     Open,
00079     Closing,
00080 
00081     Unconnected = Bound,
00082     Connected = Open,
00083     Connection = Open
00084   };
00085 
00086 public:
00092   KClientSocketBase(QObject* parent);
00093 
00097   virtual ~KClientSocketBase();
00098 
00103   SocketState state() const;
00104 
00105 protected:
00109   virtual bool setSocketOptions(int opts);
00110 
00111 public:
00120   KResolver& peerResolver() const;
00121 
00125   const KResolverResults& peerResults() const;
00126 
00135   KResolver& localResolver() const;
00136 
00140   const KResolverResults& localResults() const;
00141 
00156   void setResolutionEnabled(bool enable);
00157 
00164   void setFamily(int families);
00165 
00183   virtual bool lookup();
00184 
00204   virtual bool bind(const QString& node = QString(),
00205             const QString& service = QString()) = 0;
00206 
00215   virtual bool bind(const KResolverEntry& address);
00216 
00246   virtual bool connect(const QString& node = QString(),
00247                const QString& service = QString(),
00248                OpenMode mode = ReadWrite) = 0;
00249 
00254   virtual bool connect(const KResolverEntry& address,
00255                OpenMode mode = ReadWrite);
00256 
00261   virtual bool disconnect();
00262 
00268   virtual bool open(OpenMode mode);
00269 
00276   virtual void close();
00277 
00282   virtual bool flush();
00283 
00288   virtual qint64 bytesAvailable() const;
00289 
00293   virtual qint64 waitForMore(int msecs, bool *timeout = 0L);
00294 
00298   virtual KSocketAddress localAddress() const;
00299 
00303   virtual KSocketAddress peerAddress() const;
00304 
00308   bool emitsReadyRead() const;
00309 
00316   virtual void enableRead(bool enable);
00317 
00321   bool emitsReadyWrite() const;
00322 
00329   virtual void enableWrite(bool enable);
00330 
00331 protected Q_SLOTS:
00332   // protected slots
00333 
00343   virtual void slotReadActivity();
00344 
00354   virtual void slotWriteActivity();
00355 
00356 private Q_SLOTS:
00357   void lookupFinishedSlot();
00358 
00359 Q_SIGNALS:
00368   void stateChanged(int newstate);
00369 
00375   void gotError(int code);
00376 
00380   void hostFound();
00381 
00388   void bound(const KNetwork::KResolverEntry& local);
00389 
00405   void aboutToConnect(const KNetwork::KResolverEntry& remote, bool& skip);
00406 
00413   void connected(const KNetwork::KResolverEntry& remote);
00414 
00419   void closed();
00420 
00421 #if 0
00422   // QIODevice already has this
00431   void readyRead();
00432 #endif
00433 
00445   void readyWrite();
00446 
00447 protected:
00451   virtual qint64 readData(char *data, qint64 maxlen, KSocketAddress *from);
00452 
00456   virtual qint64 peekData(char *data, qint64 maxlen, KSocketAddress *from);
00457 
00462   virtual qint64 writeData(const char *data, qint64 len, const KSocketAddress* to);
00463 
00468   void setState(SocketState state);
00469 
00479   virtual void stateChanging(SocketState newState);
00480 
00485   void copyError();
00486 
00487 private:
00488   KClientSocketBase(const KClientSocketBase&);
00489   KClientSocketBase& operator=(const KClientSocketBase&);
00490 
00491   KClientSocketBasePrivate* const d;
00492 };
00493 
00494 }               // namespace KNetwork
00495 
00496 #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