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

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • network
k3clientsocketbase.h
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * Copyright (C) 2003,2005 Thiago Macieira <thiago@kde.org>
3  *
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef KCLIENTSOCKETBASE_H
26 #define KCLIENTSOCKETBASE_H
27 
28 #include <QtCore/QObject>
29 #include <QtCore/QString>
30 
31 #include <kdecore_export.h>
32 #include "k3socketbase.h"
33 #include "k3resolver.h"
34 
35 namespace KNetwork {
36 
37 class KClientSocketBasePrivate;
50 class KDECORE_EXPORT_DEPRECATED KClientSocketBase : public KActiveSocketBase
51 {
52  Q_OBJECT
53 
54 public:
72  enum SocketState
73  {
74  Idle,
75  HostLookup,
76  HostFound,
77  Bound,
78  Connecting,
79  Open,
80  Closing,
81 
82  Unconnected = Bound,
83  Connected = Open,
84  Connection = Open
85  };
86 
87 public:
93  KClientSocketBase(QObject* parent);
94 
98  virtual ~KClientSocketBase();
99 
104  SocketState state() const;
105 
106 protected:
110  virtual bool setSocketOptions(int opts);
111 
112 public:
121  KResolver& peerResolver() const;
122 
126  const KResolverResults& peerResults() const;
127 
136  KResolver& localResolver() const;
137 
141  const KResolverResults& localResults() const;
142 
157  void setResolutionEnabled(bool enable);
158 
165  void setFamily(int families);
166 
184  virtual bool lookup();
185 
205  virtual bool bind(const QString& node = QString(),
206  const QString& service = QString()) = 0;
207 
216  virtual bool bind(const KResolverEntry& address);
217 
247  virtual bool connect(const QString& node = QString(),
248  const QString& service = QString(),
249  OpenMode mode = ReadWrite) = 0;
250 
255  virtual bool connect(const KResolverEntry& address,
256  OpenMode mode = ReadWrite);
257 
262  virtual bool disconnect();
263 
269  virtual bool open(OpenMode mode);
270 
277  virtual void close();
278 
283  virtual bool flush();
284 
289  virtual qint64 bytesAvailable() const;
290 
294  virtual qint64 waitForMore(int msecs, bool *timeout = 0L);
295 
299  virtual KSocketAddress localAddress() const;
300 
304  virtual KSocketAddress peerAddress() const;
305 
309  bool emitsReadyRead() const;
310 
317  virtual void enableRead(bool enable);
318 
322  bool emitsReadyWrite() const;
323 
330  virtual void enableWrite(bool enable);
331 
332 protected Q_SLOTS:
333  // protected slots
334 
344  virtual void slotReadActivity();
345 
355  virtual void slotWriteActivity();
356 
357 private Q_SLOTS:
358  void lookupFinishedSlot();
359 
360 Q_SIGNALS:
369  void stateChanged(int newstate);
370 
376  void gotError(int code);
377 
381  void hostFound();
382 
389  void bound(const KNetwork::KResolverEntry& local);
390 
406  void aboutToConnect(const KNetwork::KResolverEntry& remote, bool& skip);
407 
414  void connected(const KNetwork::KResolverEntry& remote);
415 
420  void closed();
421 
422 #if 0
423  // QIODevice already has this
432  void readyRead();
433 #endif
434 
446  void readyWrite();
447 
448 protected:
452  virtual qint64 readData(char *data, qint64 maxlen, KSocketAddress *from);
453 
457  virtual qint64 peekData(char *data, qint64 maxlen, KSocketAddress *from);
458 
463  virtual qint64 writeData(const char *data, qint64 len, const KSocketAddress* to);
464 
469  void setState(SocketState state);
470 
480  virtual void stateChanging(SocketState newState);
481 
486  void copyError();
487 
488 private:
489  KClientSocketBase(const KClientSocketBase&);
490  KClientSocketBase& operator=(const KClientSocketBase&);
491 
492  KClientSocketBasePrivate* const d;
493 };
494 
495 } // namespace KNetwork
496 
497 #endif
qint64
KNetwork::KClientSocketBase::Idle
Definition: k3clientsocketbase.h:74
KNetwork::KClientSocketBase::HostLookup
Definition: k3clientsocketbase.h:75
kdecore_export.h
KNetwork::KActiveSocketBase
Abstract class for active sockets.
Definition: k3socketbase.h:461
timeout
int timeout
Definition: kkernel_mac.cpp:46
KNetwork::KResolverEntry
One resolution entry.
Definition: k3resolver.h:68
KNetwork::KClientSocketBase::Open
Definition: k3clientsocketbase.h:79
KNetwork::KResolver
Name and service resolution class.
Definition: k3resolver.h:312
KNetwork::KClientSocketBase::Bound
Definition: k3clientsocketbase.h:77
KNetwork::KSocketAddress
A generic socket address.
Definition: k3socketaddress.h:414
KNetwork::KResolverResults
Name and service resolution results.
Definition: k3resolver.h:212
KDE::open
int open(const QString &pathname, int flags, mode_t mode)
Definition: kde_file_win.cpp:158
KNetwork::KClientSocketBase::Closing
Definition: k3clientsocketbase.h:80
QObject
KNetwork::KClientSocketBase::SocketState
SocketState
Socket states.
Definition: k3clientsocketbase.h:72
QString
KNetwork::KClientSocketBase::HostFound
Definition: k3clientsocketbase.h:76
k3resolver.h
k3socketbase.h
lookup
static QByteArray lookup(const KConfigIniBackend::BufferFragment &fragment, QHash< KConfigIniBackend::BufferFragment, QByteArray > *cache)
Definition: kconfigini.cpp:43
KNetwork::KClientSocketBase::Connecting
Definition: k3clientsocketbase.h:78
KNetwork::KClientSocketBase
Abstract client socket class.
Definition: k3clientsocketbase.h:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal