# class KLocalSocket

###

Module | kdecore
Namespace |
Class | KLocalSocket
Inherits | QTcpSocket

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

Author Thiago Macieira <thiago@kde.org>

### enums

- LocalSocketType { UnixSocket, AbstractUnixSocket, UnknownLocalSocketType }

enum details

### methods

- KLocalSocket (parent)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  parent | QObject | 0

  Creates a KLocalSocket object with parent as the parent object.

  parent - the parent object

- KLocalSocket (a0)

  returns ctor
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  a0 | KLocalSocket |

- KLocalSocket (a0)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QObject | 0

- connectToHostImplementation (hostName, port, mode)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  hostName | QString |
  port | quint16 |
  mode | QIODevice.OpenMode |

  Internal

- connectToPath (path, mode)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  path | QString |
  mode | QIODevice.OpenMode | QIODevice.ReadWrite

  Opens a connection to a listening Unix socket at path. Use waitForConnection() to find out if the connection succeeded or not.

  path - the Unix socket to connect to

  mode - the mode to use when opening (see QIODevice.OpenMode)

- connectToPath (path, type, mode)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  path | QString |
  type | KLocalSocket.LocalSocketType |
  mode | QIODevice.OpenMode | 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.

  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 ( )

  returns Nothing

- disconnectFromPath ( )

  returns Nothing

  Disconnects the socket from its server.

- localPath ( )

  returns QString

  Returns the local address of this socket, when connected. Returns QString() if not connected.

  Most of the time, the socket has no local address.

- localSocketType ( )

  returns KLocalSocket.LocalSocketType

  Returns the socket type for this socket, when connected. Returns UnknownLocalSocketType if not connected.

- peerPath ( )

  returns QString

  Returns the peer address of this socket. That is, the address that this socket connected to (see connectToPath). Returns QString() if not connected.

### enums - detail

- LocalSocketType { UnixSocket, AbstractUnixSocket, UnknownLocalSocketType }

  Defines the local socket type. See KLocalSocket for more information

  | UnixSocket | - | - |
  | AbstractUnixSocket | - | - |
  | UnknownLocalSocketType | - -1 | - |