KDECore
#include <klocalsocket.h>
Public Types | |
enum | LocalSocketType { UnixSocket, AbstractUnixSocket, UnknownLocalSocketType = -1 } |
Public Member Functions | |
KLocalSocket (QObject *parent=0) | |
virtual | ~KLocalSocket () |
void | connectToPath (const QString &path, OpenMode mode=ReadWrite) |
void | connectToPath (const QString &path, LocalSocketType type, OpenMode mode=ReadWrite) |
void | disconnectFromPath () |
QString | localPath () const |
LocalSocketType | localSocketType () const |
QString | peerPath () const |
Public Member Functions inherited from QTcpSocket | |
QTcpSocket (QObject *parent) | |
virtual | ~QTcpSocket () |
Public Member Functions inherited from QAbstractSocket | |
QAbstractSocket (SocketType socketType, QObject *parent) | |
virtual | ~QAbstractSocket () |
void | abort () |
virtual bool | atEnd () const |
virtual qint64 | bytesAvailable () const |
virtual qint64 | bytesToWrite () const |
virtual bool | canReadLine () const |
virtual void | close () |
void | connected () |
void | connectionClosed () |
void | connectToHost (const QHostAddress &address, quint16 port, QFlags< QIODevice::OpenModeFlag > openMode) |
void | connectToHost (const QString &hostName, quint16 port, QFlags< QIODevice::OpenModeFlag > openMode) |
void | delayedCloseFinished () |
void | disconnected () |
void | disconnectFromHost () |
void | error (QAbstractSocket::SocketError socketError) |
SocketError | error () const |
bool | flush () |
void | hostFound () |
virtual bool | isSequential () const |
bool | isValid () const |
QHostAddress | localAddress () const |
quint16 | localPort () const |
QHostAddress | peerAddress () const |
QString | peerName () const |
quint16 | peerPort () const |
QNetworkProxy | proxy () const |
void | proxyAuthenticationRequired (const QNetworkProxy &proxy, QAuthenticator *authenticator) |
qint64 | readBufferSize () const |
void | setProxy (const QNetworkProxy &networkProxy) |
void | setReadBufferSize (qint64 size) |
void | setSocket (int socket) |
bool | setSocketDescriptor (int socketDescriptor, SocketState socketState, QFlags< QIODevice::OpenModeFlag > openMode) |
void | setSocketOption (QAbstractSocket::SocketOption option, const QVariant &value) |
int | socket () const |
int | socketDescriptor () const |
QVariant | socketOption (QAbstractSocket::SocketOption option) |
SocketType | socketType () const |
SocketState | state () const |
void | stateChanged (QAbstractSocket::SocketState socketState) |
virtual bool | waitForBytesWritten (int msecs) |
bool | waitForConnected (int msecs) |
bool | waitForDisconnected (int msecs) |
qulonglong | waitForMore (int msecs, bool *timeout) const |
virtual bool | waitForReadyRead (int msecs) |
Public Member Functions inherited from QIODevice | |
QIODevice () | |
QIODevice (QObject *parent) | |
virtual | ~QIODevice () |
void | aboutToClose () |
Offset | at () const |
bool | at (Offset offset) |
void | bytesWritten (qint64 bytes) |
QString | errorString () const |
int | flags () const |
int | getch () |
bool | getChar (char *c) |
bool | isAsynchronous () const |
bool | isBuffered () const |
bool | isCombinedAccess () const |
bool | isDirectAccess () const |
bool | isInactive () const |
bool | isOpen () const |
bool | isRaw () const |
bool | isReadable () const |
bool | isSequentialAccess () const |
bool | isSynchronous () const |
bool | isTextModeEnabled () const |
bool | isTranslated () const |
bool | isWritable () const |
int | mode () const |
virtual bool | open (QFlags< QIODevice::OpenModeFlag > mode) |
OpenMode | openMode () const |
qint64 | peek (char *data, qint64 maxSize) |
QByteArray | peek (qint64 maxSize) |
virtual qint64 | pos () const |
int | putch (int ch) |
bool | putChar (char c) |
qint64 | read (char *data, qint64 maxSize) |
QByteArray | read (qint64 maxSize) |
QByteArray | readAll () |
qint64 | readBlock (char *data, quint64 size) |
void | readChannelFinished () |
QByteArray | readLine (qint64 maxSize) |
qint64 | readLine (char *data, qint64 maxSize) |
void | readyRead () |
virtual bool | reset () |
void | resetStatus () |
virtual bool | seek (qint64 pos) |
void | setTextModeEnabled (bool enabled) |
virtual qint64 | size () const |
int | state () const |
Status | status () const |
int | ungetch (int ch) |
void | ungetChar (char c) |
qint64 | write (const char *data) |
qint64 | write (const char *data, qint64 maxSize) |
qint64 | write (const QByteArray &byteArray) |
qint64 | writeBlock (const QByteArray &data) |
qint64 | writeBlock (const char *data, quint64 size) |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Protected Slots | |
void | connectToHostImplementation (const QString &hostName, quint16 port, OpenMode mode) |
void | disconnectFromHostImplementation () |
Additional Inherited Members | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Public Attributes inherited from QAbstractSocket | |
typedef | State |
Public Attributes inherited from QIODevice | |
typedef | Offset |
typedef | OpenMode |
typedef | Status |
Protected Member Functions inherited from QAbstractSocket | |
void | connectToHostImplementation (const QString &hostName, quint16 port, QFlags< QIODevice::OpenModeFlag > openMode) |
void | disconnectFromHostImplementation () |
virtual qint64 | readData (char *data, qint64 maxSize) |
virtual qint64 | readLineData (char *data, qint64 maxlen) |
void | setLocalAddress (const QHostAddress &address) |
void | setLocalPort (quint16 port) |
void | setPeerAddress (const QHostAddress &address) |
void | setPeerName (const QString &name) |
void | setPeerPort (quint16 port) |
void | setSocketError (SocketError socketError) |
void | setSocketState (SocketState state) |
virtual qint64 | writeData (const char *data, qint64 size) |
Protected Member Functions inherited from QIODevice | |
virtual qint64 | readData (char *data, qint64 maxSize)=0 |
void | setErrorString (const QString &str) |
void | setOpenMode (QFlags< QIODevice::OpenModeFlag > openMode) |
virtual qint64 | writeData (const char *data, qint64 maxSize)=0 |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Properties inherited from QObject | |
objectName | |
Detailed Description
KLocalSocket allows one to create and use local (Unix) sockets.
On some platforms, local sockets are a kind of streaming socket that can be used to transmit and receive data just like Internet (TCP) streaming sockets. The difference is that they remain local to the host running them and cannot be accessed externally. They are also very fast and (in theory) consume less resources than standard TCP sockets.
KLocalSocket supports two kinds of local socket types (see KLocalSocket::LocalSocketType):
- Unix sockets (UnixSocket): standard Unix sockets whose names are file paths and obey filesystem restrictions
- Abstract Unix sockets (AbstractUnixSocket): similar to Unix sockets, but they don't exist as entries in the filesystem and, thus, aren't restricted by its permissions
Definition at line 51 of file klocalsocket.h.
Member Enumeration Documentation
Defines the local socket type.
See KLocalSocket for more information
Enumerator | |
---|---|
UnixSocket |
Unix sockets. |
AbstractUnixSocket |
Abstract Unix sockets. |
UnknownLocalSocketType |
Definition at line 59 of file klocalsocket.h.
Constructor & Destructor Documentation
|
explicit |
Creates a KLocalSocket object with parent
as the parent object.
- Parameters
-
parent the parent object
Definition at line 44 of file klocalsocket.cpp.
|
virtual |
Destroys the KLocalSocket object and frees up any resources associated.
If the socket is open, it will be closed.
Definition at line 49 of file klocalsocket.cpp.
Member Function Documentation
|
protectedslot |
Definition at line 67 of file klocalsocket.cpp.
Opens a connection to a listening Unix socket at path
.
Use waitForConnection() to find out if the connection succeeded or not.
- Parameters
-
path the Unix socket to connect to mode the mode to use when opening (see QIODevice::OpenMode)
Definition at line 55 of file klocalsocket.cpp.
void KLocalSocket::connectToPath | ( | const QString & | path, |
LocalSocketType | type, | ||
OpenMode | mode = ReadWrite |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Opens a connection to a listening local socket at address path
.
Use waitForConnection() to find out if the connection succeeded or not.
- Parameters
-
path the local socket address to connect to type the local socket type to use mode the mode to use when opening (see QIODevice::OpenMode)
Definition at line 61 of file klocalsocket.cpp.
|
protectedslot |
Definition at line 81 of file klocalsocket.cpp.
void KLocalSocket::disconnectFromPath | ( | ) |
Disconnects the socket from its server.
Definition at line 90 of file klocalsocket.cpp.
QString KLocalSocket::localPath | ( | ) | const |
Returns the local address of this socket, when connected.
Returns QString() if not connected.
Most of the time, the socket has no local address.
Definition at line 101 of file klocalsocket.cpp.
KLocalSocket::LocalSocketType KLocalSocket::localSocketType | ( | ) | const |
Returns the socket type for this socket, when connected.
Returns UnknownLocalSocketType if not connected.
Definition at line 96 of file klocalsocket.cpp.
QString KLocalSocket::peerPath | ( | ) | const |
Returns the peer address of this socket.
That is, the address that this socket connected to (see connectToPath). Returns QString() if not connected.
Definition at line 106 of file klocalsocket.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:13 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.