• 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
klocalsocket.h
Go to the documentation of this file.
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 2007 Thiago Macieira <thiago@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef KLOCALSOCKET_H
22 #define KLOCALSOCKET_H
23 
24 #include <kdecore_export.h>
25 #include <QtCore/QString>
26 #include <QtNetwork/QTcpSocket>
27 #include <QtNetwork/QTcpServer>
28 
29 class KLocalSocketPrivate;
51 class KDECORE_EXPORT KLocalSocket : public QTcpSocket
52 {
53  Q_OBJECT
54 public:
59  enum LocalSocketType {
60  UnixSocket,
61  AbstractUnixSocket,
62  UnknownLocalSocketType = -1
63  };
64 
71  explicit KLocalSocket(QObject *parent = 0);
76  virtual ~KLocalSocket();
77 
86  void connectToPath(const QString &path, OpenMode mode = ReadWrite);
97  void connectToPath(const QString &path, LocalSocketType type, OpenMode mode = ReadWrite);
101  void disconnectFromPath();
102 
108  LocalSocketType localSocketType() const;
109 
116  QString localPath() const;
122  QString peerPath() const;
123 
124 private:
125  using QAbstractSocket::connectToHost;
126  using QAbstractSocket::disconnectFromHost;
127 
128 protected Q_SLOTS:
130  void connectToHostImplementation(const QString &hostName, quint16 port, OpenMode mode);
131  void disconnectFromHostImplementation();
132 
133 private:
134  Q_DISABLE_COPY(KLocalSocket)
135  friend class KLocalSocketPrivate;
136  KLocalSocketPrivate * const d;
137 };
138 
139 class KLocalSocketServerPrivate;
159 class KDECORE_EXPORT KLocalSocketServer : public QObject
160 {
161  Q_OBJECT
162 public:
170  explicit KLocalSocketServer(QObject *parent = 0);
182  virtual ~KLocalSocketServer();
183 
207  bool listen(const QString &path, KLocalSocket::LocalSocketType type = KLocalSocket::UnixSocket);
208 
217  void close();
218 
222  bool isListening() const;
223 
235  void setMaxPendingConnections(int numConnections);
239  int maxPendingConnections() const;
240 
245  KLocalSocket::LocalSocketType localSocketType() const;
250  QString localPath() const;
251 
273  bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
274 
279  virtual bool hasPendingConnections() const;
288  virtual KLocalSocket *nextPendingConnection();
289 
293  QAbstractSocket::SocketError serverError() const;
297  QString errorString() const;
298 
299 protected:
301  virtual void incomingConnection(int handle);
302 
303 Q_SIGNALS:
310  void newConnection();
311 
312 private:
313  Q_PRIVATE_SLOT(d, void _k_newConnectionActivity())
314  Q_DISABLE_COPY(KLocalSocketServer)
315  friend class KLocalSocketServerPrivate;
316  KLocalSocketServerPrivate * const d;
317 };
318 
319 #endif
kdecore_export.h
QIODevice::errorString
QString errorString() const
KLocalSocket::AbstractUnixSocket
Abstract Unix sockets.
Definition: klocalsocket.h:61
KSocketFactory::listen
QTcpServer * listen(const QString &protocol, const QHostAddress &address=QHostAddress::Any, quint16 port=0, QObject *parent=0)
Opens a TCP/IP socket for listening protocol protocol, binding only at address address.
Definition: ksocketfactory.cpp:115
QAbstractSocket::connectToHost
void connectToHost(const QString &hostName, quint16 port, QFlags< QIODevice::OpenModeFlag > openMode)
QAbstractSocket::close
virtual void close()
KLocalSocketServerPrivate
Definition: klocalsocket_p.h:51
QObject
QString
KLocalSocket
KLocalSocket allows one to create and use local (Unix) sockets.
Definition: klocalsocket.h:51
QAbstractSocket::connectToHostImplementation
void connectToHostImplementation(const QString &hostName, quint16 port, QFlags< QIODevice::OpenModeFlag > openMode)
KLocalSocketServer
KLocalSocketServer allows one to create a listening local socket and accept incoming connections...
Definition: klocalsocket.h:159
QAbstractSocket::disconnectFromHost
void disconnectFromHost()
KLocalSocketPrivate
Definition: klocalsocket_p.h:30
KLocalSocket::UnixSocket
Unix sockets.
Definition: klocalsocket.h:60
QTcpSocket
KLocalSocket::LocalSocketType
LocalSocketType
Defines the local socket type.
Definition: klocalsocket.h:59
QAbstractSocket::disconnectFromHostImplementation
void disconnectFromHostImplementation()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 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