kstreamsocket.h
00001 /* -*- C++ -*- 00002 * Copyright (C) 2003 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 KSTREAMSOCKET_H 00026 #define KSTREAMSOCKET_H 00027 00028 #include <tqstring.h> 00029 00030 #include "kclientsocketbase.h" 00031 00033 namespace KNetwork { 00034 00035 class KResolverEntry; 00036 class KResolverResults; 00037 class TDEServerSocket; 00038 class TDEBufferedSocket; 00039 00040 class KStreamSocketPrivate; 00097 class TDECORE_EXPORT KStreamSocket: public KClientSocketBase 00098 { 00099 Q_OBJECT 00100 00101 00102 public: 00111 KStreamSocket(const TQString& node = TQString::null, const TQString& service = TQString::null, 00112 TQObject* parent = 0L, const char *name = 0L); 00113 00117 virtual ~KStreamSocket(); 00118 00122 int timeout() const; 00123 00128 int remainingTimeout() const; 00129 00140 void setTimeout(int msecs); 00141 00165 virtual bool bind(const TQString& node = TQString::null, 00166 const TQString& service = TQString::null); 00167 00176 virtual bool bind(const KResolverEntry& entry) 00177 { return KClientSocketBase::bind(entry); } 00178 00200 virtual bool connect(const TQString& node = TQString::null, 00201 const TQString& service = TQString::null); 00202 00206 virtual bool connect(const KResolverEntry& entry); 00207 00208 signals: 00212 void timedOut(); 00213 00214 private slots: 00215 void hostFoundSlot(); 00216 void connectionEvent(); 00217 void timeoutSlot(); 00218 00219 private: 00227 bool bindLocallyFor(const KResolverEntry& peer); 00228 00237 void connectionSucceeded(const KResolverEntry& peer); 00238 00239 KStreamSocket(const KStreamSocket&); 00240 KStreamSocket& operator=(const KStreamSocket&); 00241 00242 KStreamSocketPrivate *d; 00243 00244 friend class TDEServerSocket; 00245 friend class TDEBufferedSocket; 00246 }; 00247 00248 } // namespace KNetwork 00249 00250 #endif