# class TCPSlaveBase

###

Module | kio
Namespace | KIO
Class | TCPSlaveBase
Inherits | KIO::SlaveBase

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.

### enums

- SslResult { ResultOk, ResultFailed, ResultOverridden }
- SslResultDetail { ResultOk, ResultOverridden, ResultFailed, ResultFailedEarly }

enum details

### methods

- TCPSlaveBase (protocol, poolSocket, appSocket, autoSsl)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  protocol | QByteArray |
  poolSocket | QByteArray |
  appSocket | QByteArray |
  autoSsl | bool | 0

  Constructor.

  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.

- atEnd ( )

  returns bool

  Returns true when end of data is reached.

- connectToHost (protocol, host, port)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  protocol | QString |
  host | QString |
  port | quint16 |

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

  Please note that unlike its deprecated counterpart, this function allows you to disable any error message from being sent back to the calling application! You can then use the connectResult() function to determine the result of the request for connection.

  protocol - the protocol being used

  host - hostname

  port - port number

  sendError - if true sends error message to calling app on error.

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

- disconnectFromHost ( )

  returns Nothing

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

- isAutoSsl ( )

  returns bool

  Will start SSL after connecting?

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

- isConnected ( )

  returns bool

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

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

- isUsingSsl ( )

  returns bool

  Is the current connection using SSL?

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

- port ( )

  returns quint16

  the current port for this service

- read (data, len)

  returns ssize_t

  Argument | Type | Default
  --- | --- | ---
  data | char |
  len | ssize_t |

  Read incoming data from the remote host.

  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

- readLine (data, len)

  returns ssize_t

  Argument | Type | Default
  --- | --- | ---
  data | char |
  len | ssize_t |

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

- setBlocking (b)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  b | bool |

  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.

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

- socket ( )

  returns QIODevice

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

- startSsl ( )

  returns bool

  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 (id, data)

  returns Nothing
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  id | int |
  data | void |

- waitForResponse (t)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  t | int |

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

  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.

- write (data, len)

  returns ssize_t

  Argument | Type | Default
  --- | --- | ---
  data | char |
  len | ssize_t |

  Send data to the remote host.

  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

### enums - detail

- SslResult { ResultOk, ResultFailed, ResultOverridden }

  | ResultOk | - | - |
  | ResultFailed | - | - |
  | ResultOverridden | - | - |

- SslResultDetail { ResultOk, ResultOverridden, ResultFailed, ResultFailedEarly }

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