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

KDECore

k3datagramsocket.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 KDATAGRAMSOCKET_H
00026 #define KDATAGRAMSOCKET_H
00027 
00028 #include <QtCore/QByteArray>
00029 
00030 #include "k3socketaddress.h"
00031 #include "k3clientsocketbase.h"
00032 
00033 namespace KNetwork {
00034 
00035 class KResolverEntry;
00036 
00052 class KDECORE_EXPORT KDatagramPacket //krazy:exclude=dpointer,inline (lightweight; kde3)
00053 {
00054   QByteArray m_data;
00055   KSocketAddress m_address;
00056 
00057 public:
00061   KDatagramPacket()
00062   { }
00063 
00067   explicit KDatagramPacket(const QByteArray& content)
00068     : m_data(content)
00069   { }
00070 
00076   KDatagramPacket(const char* content, uint length)
00077   { setData(content, length); }
00078 
00082   KDatagramPacket(const QByteArray& content, const KSocketAddress& addr)
00083     : m_data(content), m_address(addr)
00084   { }
00085 
00089   KDatagramPacket(const char *content, uint length, const KSocketAddress& addr)
00090     : m_address(addr)
00091   { setData(content, length); }
00092 
00096   KDatagramPacket(const KDatagramPacket& other)
00097   { *this = other; }
00098 
00102   ~KDatagramPacket()
00103   { }
00104 
00108   const QByteArray& data() const
00109   { return m_data; }
00110 
00114   uint length() const
00115   { return m_data.size(); }
00116 
00120   uint size() const
00121   { return m_data.size(); }
00122 
00126   bool isEmpty() const
00127   { return m_data.isEmpty(); }
00128 
00132   bool isNull() const
00133   { return m_data.isNull(); }
00134 
00138   const KSocketAddress& address() const
00139   { return m_address; }
00140 
00144   void setAddress(const KSocketAddress& addr)
00145   { m_address = addr; }
00146 
00151   void detach()
00152   { m_data.detach(); }
00153 
00157   void setData(const QByteArray& data)
00158   { m_data = data; }
00159 
00163   void setData(const char* data, uint length)
00164   { m_data = QByteArray(data, length); }
00165 };
00166 
00167 class KDatagramSocketPrivate;
00182 class KDECORE_EXPORT KDatagramSocket: public KClientSocketBase
00183 {
00184   Q_OBJECT
00185 
00186 public:
00190   KDatagramSocket(QObject* parent = 0L);
00191 
00195   virtual ~KDatagramSocket();
00196 
00200   //  virtual bool lookup();
00201 
00210   virtual bool bind(const QString& node = QString(),
00211             const QString& service = QString());
00212 
00217   virtual bool bind(const KResolverEntry& entry);
00218 
00231   virtual bool connect(const QString& node = QString(),
00232                const QString& service = QString(),
00233                OpenMode mode = ReadWrite);
00234 
00239   virtual bool connect(const KResolverEntry& entry, OpenMode mode = ReadWrite);
00240 
00247   virtual KDatagramPacket receive();
00248 
00259   virtual qint64 send(const KDatagramPacket& packet);
00260 
00261 protected:
00265   virtual qint64 writeData(const char *data, qint64 len, const KSocketAddress* to);
00266 
00267 private Q_SLOTS:
00268   void lookupFinishedLocal();
00269   void lookupFinishedPeer();
00270 
00271 private:
00272   bool doBind();
00273   void setupSignals();
00274 
00275   KDatagramSocketPrivate* const d;
00276 };
00277 
00278 }               // namespace KNetwork
00279 
00280 #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
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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