KIO.Connection

KDE 4.2 PyKDE API Reference

- KDE's Python API

# Connection Class Reference

`from PyKDE4.kio import *`

Inherits: QObject
Namespace: KIO

## Detailed Description

This class provides a simple means for IPC between two applications via a pipe. It handles a queue of commands to be sent which makes it possible to queue data before an actual connection has been established.

## Signals
| readyRead ()
## Methods
| __init__ (self, QObject parent=0)
| close (self)
| connectToRemote (self, QString address)
QString | errorString (self)
bool | hasTaskAvailable (self)
bool | inited (self)
bool | isConnected (self)
int | read (self, int _cmd, QByteArray data)
| readyRead (self)
| resume (self)
bool | send (self, int cmd, QByteArray arr=QByteArray())
bool | sendnow (self, int _cmd, QByteArray data)
| suspend (self)
bool | suspended (self)
bool | waitForIncomingTask (self, int ms=30000)

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

Creates a new connection.

See also:
  connectToRemote, listenForRemote

close | ( |  | self ) |

Closes the connection.

connectToRemote | ( | self, |
|  | QString | address
| ) |  |  |

Connects to the remote address.

QString errorString | ( |  | self ) |

bool hasTaskAvailable | ( |  | self ) |

Returns true if there are packets to be read immediately, false if waitForIncomingTask must be called before more data is available.

bool inited | ( |  | self ) |

Checks whether the connection has been initialized.

Returns:
  true if the initialized

See also:
  init()

bool isConnected | ( |  | self ) |

int read | ( | self, |
|  | int | _cmd,
|  | QByteArray | data
| ) |  |  |

Receive data.

Parameters:

  | _cmd | the received command will be written here
  | data | the received data will be written here

Returns:
  >=0 indicates the received data size upon success -1 indicates error

readyRead | ( |  | self ) |

Signal syntax:
  `QObject.connect(source, SIGNAL("readyRead()"), target_slot)`

resume | ( |  | self ) |

Resume handling of incoming data.

bool send | ( | self, |
|  | int | cmd,
|  | QByteArray | arr=QByteArray()
| ) |  |  |

Sends/queues the given command to be sent.

Parameters:

  | cmd | the command to set
  | arr | the bytes to send

Returns:
  true if successful, false otherwise

bool sendnow | ( | self, |
|  | int | _cmd,
|  | QByteArray | data
| ) |  |  |

Sends the given command immediately.

Parameters:

  | _cmd | the command to set
  | data | the bytes to send

Returns:
  true if successful, false otherwise

suspend | ( |  | self ) |

Don't handle incoming data until resumed.

bool suspended | ( |  | self ) |

Returns status of connection.

Returns:
  true if suspended, false otherwise

bool waitForIncomingTask | ( | self, |
|  | int | ms=30000
| ) |  |  |

Waits for one more command to be handled and ready.

Parameters:

  | ms | the time to wait in milliseconds

Returns:
  true if one command can be read, false if we timed out