# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kdatagramsocket.h

    00001 /*  -*- C++ -*-
    00002  *  Copyright (C) 2003 Thiago Macieira <thiago.macieira@kdemail.net>
    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 <qcstring.h>
    00029
    00030 #include "ksocketaddress.h"
    00031 #include "kclientsocketbase.h"
    00032
    00033 namespace KNetwork {
    00034
    00035 class KResolverEntry;
    00036
    00051 class KDECORE_EXPORT KDatagramPacket
    00052 {
    00053   QByteArray m_data;
    00054   KSocketAddress m_address;
    00055
    00056 public:
    00060   KDatagramPacket()
    00061   { }
    00062
    00066   KDatagramPacket(const QByteArray& content)
    00067     : m_data(content)
    00068   { }
    00069
    00075   KDatagramPacket(const char* content, uint length)
    00076   { setData(content, length); }
    00077
    00081   KDatagramPacket(const QByteArray& content, const KSocketAddress& addr)
    00082     : m_data(content), m_address(addr)
    00083   { }
    00084
    00088   KDatagramPacket(const char *content, uint length, const KSocketAddress& addr)
    00089     : m_address(addr)
    00090   { setData(content, length); }
    00091
    00095   KDatagramPacket(const KDatagramPacket& other)
    00096   { *this = other; }
    00097
    00101   ~KDatagramPacket()
    00102   { }
    00103
    00107   const QByteArray& data() const
    00108   { return m_data; }
    00109
    00113   uint length() const
    00114   { return m_data.size(); }
    00115
    00119   uint size() const
    00120   { return m_data.size(); }
    00121
    00125   bool isEmpty() const
    00126   { return m_data.isEmpty(); }
    00127
    00131   bool isNull() const
    00132   { return m_data.isNull(); }
    00133
    00137   const KSocketAddress& address() const
    00138   { return m_address; }
    00139
    00143   void setAddress(const KSocketAddress& addr)
    00144   { m_address = addr; }
    00145
    00150   void detach()
    00151   { m_data.detach(); }
    00152
    00156   void setData(const QByteArray& data)
    00157   { m_data = data; }
    00158
    00162   void setData(const char* data, uint length)
    00163   { m_data.duplicate(data, length); }
    00164 };
    00165
    00166 class KDatagramSocketPrivate;
    00180 class KDECORE_EXPORT KDatagramSocket: public KClientSocketBase
    00181 {
    00182   Q_OBJECT
    00183
    00184 public:
    00188   KDatagramSocket(QObject* parent = 0L, const char *name = 0L);
    00189
    00193   virtual ~KDatagramSocket();
    00194
    00198   //  virtual bool lookup();
    00199
    00208   virtual bool bind(const QString& node = QString::null,
    00209             const QString& service = QString::null);
    00210
    00215   virtual bool bind(const KResolverEntry& entry)
    00216   { return KClientSocketBase::bind(entry); }
    00217
    00230   virtual bool connect(const QString& node = QString::null,
    00231                const QString& service = QString::null);
    00232
    00237   virtual bool connect(const KResolverEntry& entry)
    00238   { return KClientSocketBase::connect(entry); }
    00239
    00246   virtual KDatagramPacket receive();
    00247
    00258   virtual Q_LONG send(const KDatagramPacket& packet);
    00259
    00260 private slots:
    00261   void lookupFinishedLocal();
    00262   void lookupFinishedPeer();
    00263
    00264 private:
    00265   bool doBind();
    00266   void setupSignals();
    00267
    00268   KDatagramSocketPrivate *d;
    00269 };
    00270
    00271 }               // namespace KNetwork
    00272
    00273 #endif

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:18:04 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003