• Skip to content
  • Skip to link menu
KDE 4.2 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;
00050 class KDECORE_EXPORT KClientSocketBase : public KActiveSocketBase
00051 {
00052   Q_OBJECT
00053 
00054 public:
00072   enum SocketState
00073   {
00074     Idle,
00075     HostLookup,
00076     HostFound,
00077     Bound,
00078     Connecting,
00079     Open,
00080     Closing,
00081 
00082     Unconnected = Bound,
00083     Connected = Open,
00084     Connection = Open
00085   };
00086 
00087 public:
00093   KClientSocketBase(QObject* parent);
00094 
00098   virtual ~KClientSocketBase();
00099 
00104   SocketState state() const;
00105 
00106 protected:
00110   virtual bool setSocketOptions(int opts);
00111 
00112 public:
00121   KResolver& peerResolver() const;
00122 
00126   const KResolverResults& peerResults() const;
00127 
00136   KResolver& localResolver() const;
00137 
00141   const KResolverResults& localResults() const;
00142 
00157   void setResolutionEnabled(bool enable);
00158 
00165   void setFamily(int families);
00166 
00184   virtual bool lookup();
00185 
00205   virtual bool bind(const QString& node = QString(),
00206             const QString& service = QString()) = 0;
00207 
00216   virtual bool bind(const KResolverEntry& address);
00217 
00247   virtual bool connect(const QString& node = QString(),
00248                const QString& service = QString(),
00249                OpenMode mode = ReadWrite) = 0;
00250 
00255   virtual bool connect(const KResolverEntry& address,
00256                OpenMode mode = ReadWrite);
00257 
00262   virtual bool disconnect();
00263 
00269   virtual bool open(OpenMode mode);
00270 
00277   virtual void close();
00278 
00283   virtual bool flush();
00284 
00289   virtual qint64 bytesAvailable() const;
00290 
00294   virtual qint64 waitForMore(int msecs, bool *timeout = 0L);
00295 
00299   virtual KSocketAddress localAddress() const;
00300 
00304   virtual KSocketAddress peerAddress() const;
00305 
00309   bool emitsReadyRead() const;
00310 
00317   virtual void enableRead(bool enable);
00318 
00322   bool emitsReadyWrite() const;
00323 
00330   virtual void enableWrite(bool enable);
00331 
00332 protected Q_SLOTS:
00333   // protected slots
00334 
00344   virtual void slotReadActivity();
00345 
00355   virtual void slotWriteActivity();
00356 
00357 private Q_SLOTS:
00358   void lookupFinishedSlot();
00359 
00360 Q_SIGNALS:
00369   void stateChanged(int newstate);
00370 
00376   void gotError(int code);
00377 
00381   void hostFound();
00382 
00389   void bound(const KNetwork::KResolverEntry& local);
00390 
00406   void aboutToConnect(const KNetwork::KResolverEntry& remote, bool& skip);
00407 
00414   void connected(const KNetwork::KResolverEntry& remote);
00415 
00420   void closed();
00421 
00422 #if 0
00423   // QIODevice already has this
00432   void readyRead();
00433 #endif
00434 
00446   void readyWrite();
00447 
00448 protected:
00452   virtual qint64 readData(char *data, qint64 maxlen, KSocketAddress *from);
00453 
00457   virtual qint64 peekData(char *data, qint64 maxlen, KSocketAddress *from);
00458 
00463   virtual qint64 writeData(const char *data, qint64 len, const KSocketAddress* to);
00464 
00469   void setState(SocketState state);
00470 
00480   virtual void stateChanging(SocketState newState);
00481 
00486   void copyError();
00487 
00488 private:
00489   KClientSocketBase(const KClientSocketBase&);
00490   KClientSocketBase& operator=(const KClientSocketBase&);
00491 
00492   KClientSocketBasePrivate* const d;
00493 };
00494 
00495 }               // namespace KNetwork
00496 
00497 #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
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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