KLocalSocket Class Reference
from PyKDE4.kdecore import *
Inherits: QTcpSocket → QAbstractSocket → QIODevice → QObject
Detailed Description
KLocalSocket 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
Enumerations | |
LocalSocketType | { UnixSocket, AbstractUnixSocket, UnknownLocalSocketType } |
Methods | |
__init__ (self, QObject parent=0) | |
__init__ (self, KLocalSocket a0) | |
connectToHostImplementation (self, QString hostName, int port, QIODevice.OpenMode mode) | |
connectToPath (self, QString path, QIODevice.OpenMode mode=QIODevice.ReadWrite) | |
connectToPath (self, QString path, KLocalSocket.LocalSocketType type, QIODevice.OpenMode mode=QIODevice.ReadWrite) | |
disconnectFromHostImplementation (self) | |
disconnectFromPath (self) | |
QString | localPath (self) |
KLocalSocket.LocalSocketType | localSocketType (self) |
QString | peerPath (self) |
Method Documentation
__init__ | ( | self, | ||
QObject | parent=0 | |||
) |
Creates a KLocalSocket object with parent as the parent object.
- Parameters:
-
parent the parent object
__init__ | ( | self, | ||
KLocalSocket | a0 | |||
) |
connectToHostImplementation | ( | self, | ||
QString | hostName, | |||
int | port, | |||
QIODevice.OpenMode | mode | |||
) |
- Internal:
connectToPath | ( | self, | ||
QString | path, | |||
QIODevice.OpenMode | mode=QIODevice.ReadWrite | |||
) |
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)
connectToPath | ( | self, | ||
QString | path, | |||
KLocalSocket.LocalSocketType | type, | |||
QIODevice.OpenMode | mode=QIODevice.ReadWrite | |||
) |
Opens a connection to a listening local socket at address @p 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)
disconnectFromHostImplementation | ( | self ) |
disconnectFromPath | ( | self ) |
Disconnects the socket from its server.
QString localPath | ( | self ) |
Returns the local address of this socket, when connected. Returns QString() if not connected.
Most of the time, the socket has no local address.
KLocalSocket.LocalSocketType localSocketType | ( | self ) |
Returns the socket type for this socket, when connected. Returns UnknownLocalSocketType if not connected.
QString peerPath | ( | self ) |
Returns the peer address of this socket. That is, the address that this socket connected to (see connectToPath). Returns QString() if not connected.
Enumeration Documentation
LocalSocketType |
Defines the local socket type. See KLocalSocket for more information
- Enumerator:
-
UnixSocket AbstractUnixSocket UnknownLocalSocketType = -1