KIO.TCPSlaveBase

KDE 4.2 PyKDE API Reference

- KDE's Python API

# TCPSlaveBase Class Reference

`from PyKDE4.kio import *`

Inherits: KIO.SlaveBase
Namespace: KIO

## Detailed Description

There are two classes that specifies the protocol between application (job) and kioslave. SlaveInterface is the class to use on the application end, SlaveBase is the one to use on the slave end.

Slave implementations should simply inherit SlaveBase

A call to foo() results in a call to slotFoo() on the other end.

## Enumerations
SslResultDetail | { ResultOk, ResultOverridden, ResultFailed, ResultFailedEarly }
## Methods
| __init__ (self, QByteArray protocol, QByteArray poolSocket, QByteArray appSocket, bool autoSsl=0)
| __init__ (self, KIO.TCPSlaveBase other)
bool | atEnd (self)
bool | connectToHost (self, QString protocol, QString host, int port)
| disconnectFromHost (self)
bool | isAutoSsl (self)
bool | isConnected (self)
bool | isUsingSsl (self)
int | port (self)
ssize_t | read (self, QString data, ssize_t len)
ssize_t | readLine (self, QString data, ssize_t len)
| setBlocking (self, bool b)
QIODevice | socket (self)
bool | startSsl (self)
| virtual_hook (self, int id, void data)
bool | waitForResponse (self, int t)
ssize_t | write (self, QString data, ssize_t len)

## Method Documentation

__init__ | ( | self, |
|  | QByteArray | protocol,
|  | QByteArray | poolSocket,
|  | QByteArray | appSocket,
|  | bool | autoSsl=0
| ) |  |  |

Constructor.

Parameters:

  | autoSsl | if true, will automatically invoke startSsl() right after connecting. In the absence of errors the use of SSL will therefore be transparent to higher layers.

__init__ | ( | self, |
|  | KIO.TCPSlaveBase | other
| ) |  |  |

bool atEnd | ( |  | self ) |

Returns true when end of data is reached.

bool connectToHost | ( | self, |
|  | QString | protocol,
|  | QString | host,
|  | int | port
| ) |  |  |

Performs the initial TCP connection stuff and/or SSL handshaking as necessary.

Parameters:

  | protocol | the protocol being used
  | host | hostname
  | port | port number

Returns:
  on succes, true is returned. on failure, false is returned and an appropriate error message is sent to the application.

disconnectFromHost | ( |  | self ) |

Close the connection and forget non-permanent data like the peer host.

bool isAutoSsl | ( |  | self ) |

Will start SSL after connecting?

Returns:
  if so, true is returned. if not, false is returned.

bool isConnected | ( |  | self ) |

Determines whether or not we are still connected to the remote machine.

return true if the socket is still active or false otherwise.

bool isUsingSsl | ( |  | self ) |

Is the current connection using SSL?

Returns:
  if so, true is returned. if not, false is returned.

int port | ( |  | self ) |

the current port for this service

ssize_t read | ( | self, |
|  | QString | data,
|  | ssize_t | len
| ) |  |  |

Read incoming data from the remote host.

Parameters:

  | data | storage for the data read from server
  | len | length of the data (in bytes) to read from the server

Returns:
  the actual size of data that was obtained

ssize_t readLine | ( | self, |
|  | QString | data,
|  | ssize_t | len
| ) |  |  |

Same as read() except it reads data one line at a time.

setBlocking | ( | self, |
|  | bool | b
| ) |  |  |

Sets the mode of the connection to blocking or non-blocking.

Be sure to call this function before calling connectToHost. Otherwise, this setting will not have any effect until the next connectToHost.

Parameters:

  | b | true to make the connection a blocking one, false otherwise.

QIODevice socket | ( |  | self ) |

Return the socket object, if the class ever needs to do anything to it

bool startSsl | ( |  | self ) |

Start using SSL on the connection. You can use it right after connecting for classic, transparent to the protocol SSL. Calling it later can be used to implement e.g. SMTP's STARTTLS feature.

Returns:
  on success, true is returned. on failure, false is returned.

virtual_hook | ( | self, |
|  | int | id,
|  | void | data
| ) |  |  |

bool waitForResponse | ( | self, |
|  | int | t
| ) |  |  |

Wait for incoming data on the socket for the period specified by t.

Parameters:

  | t | length of time in seconds that we should monitor the socket before timing out.

Returns:
  true if any data arrived on the socket before the timeout value was reached, false otherwise.

ssize_t write | ( | self, |
|  | QString | data,
|  | ssize_t | len
| ) |  |  |

Send data to the remote host.

Parameters:

  | data | data to be sent to remote machine
  | len | the length (in bytes) of the data to be sent

Returns:
  the actual size of the data that was sent

## Enumeration Documentation

SslResultDetail

Enumerator:

  ResultOk = 1 |
  ResultOverridden = 2 |
  ResultFailed = 4 |
  ResultFailedEarly = 8 |