KDECore
k3serversocket.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 KSERVERSOCKET_H 00026 #define KSERVERSOCKET_H 00027 00028 #include <QtCore/QObject> 00029 #include "k3socketbase.h" 00030 #include "k3streamsocket.h" 00031 00032 namespace KNetwork { 00033 00034 class KStreamSocket; 00035 class KResolver; 00036 class KResolverResults; 00037 00038 class KServerSocketPrivate; 00108 class KDECORE_EXPORT KServerSocket: public QObject, public KPassiveSocketBase 00109 { 00110 Q_OBJECT 00111 public: 00121 KServerSocket(QObject* parent = 0L); 00122 00139 explicit KServerSocket(const QString& service, QObject* parent = 0L); 00140 00158 KServerSocket(const QString& node, const QString& service, 00159 QObject* parent = 0L); 00160 00167 ~KServerSocket(); 00168 00169 protected: 00173 virtual bool setSocketOptions(int opts); 00174 00175 public: 00184 KResolver& resolver() const; 00185 00189 const KResolverResults& resolverResults() const; 00190 00205 void setResolutionEnabled(bool enable); 00206 00213 void setFamily(int families); 00214 00228 void setAddress(const QString& service); 00229 00245 void setAddress(const QString& node, const QString& service); 00246 00254 void setTimeout(int msecs); 00255 00273 virtual bool lookup(); 00274 00288 virtual bool bind(const QString& node, const QString& service); 00289 00296 virtual bool bind(const QString& service); 00297 00303 virtual bool bind(); 00304 00312 virtual bool bind(const KResolverEntry& address); 00313 00327 virtual bool listen(int backlog = 5); // 5 is arbitrary 00328 00332 virtual void close(); 00333 00345 void setAcceptBuffered(bool enable); 00346 00359 virtual KStreamSocket* accept(); 00360 00364 virtual KSocketAddress localAddress() const; 00365 00369 virtual KSocketAddress externalAddress() const; 00370 00371 private Q_SLOTS: 00372 void lookupFinishedSlot(); 00373 00374 Q_SIGNALS: 00380 void gotError(int code); 00381 00385 void hostFound(); 00386 00393 void bound(const KNetwork::KResolverEntry& local); 00394 00399 void closed(); 00400 00406 void readyAccept(); 00407 00408 protected: 00413 void copyError(); 00414 00415 private: 00416 bool doBind(); 00417 bool doListen(); 00418 00419 private: 00420 KServerSocket(const KServerSocket&); 00421 KServerSocket& operator=(const KServerSocket&); 00422 00423 KServerSocketPrivate* const d; 00424 }; 00425 00426 } // namespace KNetwork 00427 00428 #endif
KDE 4.6 API Reference