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

KDECore

  • 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
29class KLocalSocketPrivate;
51class KDECORE_EXPORT KLocalSocket : public QTcpSocket
52{
53 Q_OBJECT
54public:
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
124private:
125 using QAbstractSocket::connectToHost;
126 using QAbstractSocket::disconnectFromHost;
127
128protected Q_SLOTS:
130 void connectToHostImplementation(const QString &hostName, quint16 port, OpenMode mode);
131 void disconnectFromHostImplementation();
132
133private:
134 Q_DISABLE_COPY(KLocalSocket)
135 friend class KLocalSocketPrivate;
136 KLocalSocketPrivate * const d;
137};
138
139class KLocalSocketServerPrivate;
159class KDECORE_EXPORT KLocalSocketServer : public QObject
160{
161 Q_OBJECT
162public:
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
299protected:
301 virtual void incomingConnection(int handle);
302
303Q_SIGNALS:
310 void newConnection();
311
312private:
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
KLocalSocketPrivate
Definition: klocalsocket_p.h:31
KLocalSocketServerPrivate
Definition: klocalsocket_p.h:52
KLocalSocketServer
KLocalSocketServer allows one to create a listening local socket and accept incoming connections.
Definition: klocalsocket.h:160
KLocalSocketServer::newConnection
void newConnection()
The newConnection() signal is emitted whenever a new connection is ready and has been accepted.
KLocalSocket
KLocalSocket allows one to create and use local (Unix) sockets.
Definition: klocalsocket.h:52
KLocalSocket::LocalSocketType
LocalSocketType
Defines the local socket type.
Definition: klocalsocket.h:59
KLocalSocket::AbstractUnixSocket
@ AbstractUnixSocket
Abstract Unix sockets.
Definition: klocalsocket.h:61
KLocalSocket::UnixSocket
@ UnixSocket
Unix sockets.
Definition: klocalsocket.h:60
QObject
QString
QTcpSocket
kdecore_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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