• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

tdesocketdevice.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 TDESOCKETDEVICE_H
00026 #define TDESOCKETDEVICE_H
00027 
00028 #include <tqsocketnotifier.h>
00029 #include "tdesocketbase.h"
00030 
00031 namespace KNetwork {
00032 
00033 class TDESocketDevice;
00034 class TDESocketDeviceFactoryBase;
00035 
00036 class TDESocketDevicePrivate;
00050 class TDECORE_EXPORT TDESocketDevice: public KActiveSocketBase, public KPassiveSocketBase
00051 {
00052 public:
00063   enum Capabilities
00064     {
00067       CanConnectString = 0x01,
00068 
00071       CanBindString = 0x02,
00072 
00075       CanNotBind = 0x04,
00076 
00079       CanNotListen = 0x08,
00080 
00084       CanMulticast = 0x10,
00085 
00090       CanNotUseDatagrams = 0x20
00091     };
00092 protected:
00095   int m_sockfd;
00096 
00097 public:
00104   explicit TDESocketDevice(const TDESocketBase* = 0L);
00105 
00112   explicit TDESocketDevice(int fd);
00113 
00117   virtual ~TDESocketDevice();
00118 
00122   inline int socket() const
00123   { return m_sockfd; }
00124 
00134   virtual int capabilities() const
00135   { return 0; }
00136 
00140   virtual bool setSocketOptions(int opts);
00141 
00145   virtual bool open(TQ_OpenMode mode);
00146 
00152   virtual void close();
00153 
00157   virtual void flush()
00158   { }
00159 
00164   virtual bool create(int family, int type, int protocol);
00165 
00170   bool create(const KResolverEntry& address);
00171 
00175   virtual bool bind(const KResolverEntry& address);
00176 
00180   virtual bool listen(int backlog = 5); // 5 is arbitrary
00181 
00185   virtual bool connect(const KResolverEntry& address);
00186 
00191   virtual TDESocketDevice* accept();
00192 
00196   virtual bool disconnect();
00197 
00201 #ifdef USE_QT3
00202   virtual TQ_LONG bytesAvailable() const;
00203 #endif
00204 #ifdef USE_QT4
00205   virtual qint64 bytesAvailable() const;
00206 #endif
00207 
00214   virtual TQ_LONG waitForMore(int msecs, bool *timeout = 0L);
00215 
00219   virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen);
00220 
00224   virtual TQT_TQIO_LONG tqreadBlock(char *data, TQT_TQIO_ULONG maxlen, TDESocketAddress& from);
00225 
00229   virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen);
00230 
00234   virtual TQ_LONG peekBlock(char *data, TQ_ULONG maxlen, TDESocketAddress& from);
00235 
00239   virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len);
00240 
00244   virtual TQT_TQIO_LONG tqwriteBlock(const char *data, TQT_TQIO_ULONG len, const TDESocketAddress& to);
00245 
00249   virtual TDESocketAddress localAddress() const;
00250 
00255   virtual TDESocketAddress peerAddress() const;
00256 
00271   virtual TDESocketAddress externalAddress() const;
00272 
00280   TQSocketNotifier* readNotifier() const;
00281 
00288   TQSocketNotifier* writeNotifier() const;
00289 
00296   TQSocketNotifier* exceptionNotifier() const;
00297 
00316   virtual bool poll(bool* input, bool* output, bool* exception = 0L,
00317             int timeout = -1, bool* timedout = 0L);
00318 
00330   bool poll(int timeout = -1, bool* timedout = 0L);
00331 
00332 protected:
00340   TDESocketDevice(bool, const TDESocketBase* parent = 0L);
00341 
00357   virtual TQSocketNotifier* createNotifier(TQSocketNotifier::Type type) const;
00358 
00359 public:
00370   static TDESocketDevice* createDefault(TDESocketBase* parent);
00371 
00380   static TDESocketDevice* createDefault(TDESocketBase* parent, int capabilities);
00381 
00388   static TDESocketDeviceFactoryBase* setDefaultImpl(TDESocketDeviceFactoryBase* factory);
00389 
00394   static void addNewImpl(TDESocketDeviceFactoryBase* factory, int capabilities);
00395 
00396 private:
00397   TDESocketDevice(const TDESocketDevice&);
00398   TDESocketDevice& operator=(const TDESocketDevice&);
00399 
00400   TDESocketDevicePrivate *d;
00401 };
00402 
00407 class TDESocketDeviceFactoryBase
00408 {
00409 public:
00410   TDESocketDeviceFactoryBase() {}
00411   virtual ~TDESocketDeviceFactoryBase() {}
00412 
00413   virtual TDESocketDevice* create(TDESocketBase*) const = 0;
00414 };
00415 
00420 template<class Impl>
00421 class TDESocketDeviceFactory: public TDESocketDeviceFactoryBase
00422 {
00423 public:
00424   TDESocketDeviceFactory() {}
00425   virtual ~TDESocketDeviceFactory() {}
00426 
00427   virtual TDESocketDevice* create(TDESocketBase* parent) const
00428   { return new Impl(parent); }
00429 };
00430 
00431 }               // namespaces
00432 
00433 #endif

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.7.1
This website is maintained by Timothy Pearson.