KDE 4.5 PyKDE API Reference

- KDE's Python API

# KTcpSocket Class Reference

`from PyKDE4.kdecore import *`

Inherits: QIODevice → QObject

## Detailed Description

## Enumerations
EncryptionMode | { UnencryptedMode, SslClientMode, SslServerMode }
Error | { UnknownError, ConnectionRefusedError, RemoteHostClosedError, HostNotFoundError, SocketAccessError, SocketResourceError, SocketTimeoutError, NetworkError, UnsupportedSocketOperationError }
ProxyPolicy | { AutoProxy, ManualProxy }
SslVersion | { UnknownSslVersion, SslV2, SslV3, TlsV1, SslV3_1, AnySslVersion }
State | { UnconnectedState, HostLookupState, ConnectingState, ConnectedState, BoundState, ListeningState, ClosingState }
## Signals
| connected ()
| disconnected ()
| encrypted ()
| encryptionModeChanged (KTcpSocket.EncryptionMode a0)
| error (KTcpSocket.Error a0)
| hostFound ()
| proxyAuthenticationRequired (QNetworkProxy proxy, QAuthenticator authenticator)
| sslErrors ([KSslError] errors)
| stateChanged (KTcpSocket.State a0)
## Methods
| __init__ (self, QObject parent=0)
| abort (self)
| addCaCertificate (self, QSslCertificate certificate)
| addCaCertificates (self, [QSslCertificate] certificates)
KTcpSocket.SslVersion | advertisedSslVersion (self)
bool | atEnd (self)
long | bytesAvailable (self)
long | bytesToWrite (self)
[QSslCertificate] | caCertificates (self)
bool | canReadLine (self)
[KSslCipher] | ciphers (self)
| close (self)
| connectToHost (self, QString hostName, int port, KTcpSocket.ProxyPolicy policy=KTcpSocket.AutoProxy)
| connectToHost (self, QHostAddress hostAddress, int port, KTcpSocket.ProxyPolicy policy=KTcpSocket.AutoProxy)
| connectToHost (self, KUrl url, KTcpSocket.ProxyPolicy policy=KTcpSocket.AutoProxy)
| connectToHostEncrypted (self, QString hostName, int port, QIODevice.OpenMode openMode=QIODevice.ReadWrite)
| disconnectFromHost (self)
KTcpSocket.EncryptionMode | encryptionMode (self)
KTcpSocket.Error | error (self)
bool | flush (self)
| ignoreSslErrors (self)
bool | isSequential (self)
bool | isValid (self)
QHostAddress | localAddress (self)
QSslCertificate | localCertificate (self)
KTcpSocket.SslVersion | negotiatedSslVersion (self)
QString | negotiatedSslVersionName (self)
bool | open (self, QIODevice.OpenMode open)
QHostAddress | peerAddress (self)
[QSslCertificate] | peerCertificateChain (self)
QString | peerName (self)
int | peerPort (self)
KSslKey | privateKey (self)
QNetworkProxy | proxy (self)
long | readBufferSize (self)
KSslCipher | sessionCipher (self)
| setAdvertisedSslVersion (self, KTcpSocket.SslVersion version)
| setCaCertificates (self, [QSslCertificate] certificates)
| setCiphers (self, [KSslCipher] ciphers)
| setLocalCertificate (self, QSslCertificate certificate)
| setLocalCertificate (self, QString fileName, QSsl.EncodingFormat format=QSsl.Pem)
| setPrivateKey (self, KSslKey key)
| setPrivateKey (self, QString fileName, KSslKey.Algorithm algorithm=KSslKey.Rsa, QSsl.EncodingFormat format=QSsl.Pem, QByteArray passPhrase=QByteArray())
| setProxy (self, QNetworkProxy proxy)
| setReadBufferSize (self, long size)
| setSocketOption (self, QAbstractSocket.SocketOption options, QVariant value)
QVariant | socketOption (self, QAbstractSocket.SocketOption options)
[KSslError] | sslErrors (self)
| startClientEncryption (self)
KTcpSocket.State | state (self)
bool | waitForBytesWritten (self, int msecs)
bool | waitForConnected (self, int msecs=30000)
bool | waitForDisconnected (self, int msecs=30000)
bool | waitForEncrypted (self, int msecs=30000)
bool | waitForReadyRead (self, int msecs=30000)

## Signal Documentation

connected | ( |  | ) |

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

disconnected | ( |  | ) |

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

encrypted | ( |  | ) |

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

encryptionModeChanged | ( | KTcpSocket.EncryptionMode | a0
| ) |  |  |

Signal syntax:
  `QObject.connect(source, SIGNAL("encryptionModeChanged(KTcpSocket::EncryptionMode)"), target_slot)`

error | ( | KTcpSocket.Error | a0
| ) |  |  |

Signal syntax:
  `QObject.connect(source, SIGNAL("error(KTcpSocket::Error)"), target_slot)`

hostFound | ( |  | ) |

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

proxyAuthenticationRequired | ( | QNetworkProxy | proxy,
|  | QAuthenticator | authenticator
| ) |  |  |

Signal syntax:
  `QObject.connect(source, SIGNAL("proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)"), target_slot)`

sslErrors | ( | [KSslError] | errors
| ) |  |  |

Signal syntax:
  `QObject.connect(source, SIGNAL("sslErrors(const QList&)"), target_slot)`

stateChanged | ( | KTcpSocket.State | a0
| ) |  |  |

Signal syntax:
  `QObject.connect(source, SIGNAL("stateChanged(KTcpSocket::State)"), target_slot)`

## Method Documentation

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

abort | ( |  | self ) |

addCaCertificate | ( | self, |
|  | QSslCertificate | certificate
| ) |  |  |

addCaCertificates | ( | self, |
|  | [QSslCertificate] | certificates
| ) |  |  |

KTcpSocket.SslVersion advertisedSslVersion | ( |  | self ) |

bool atEnd | ( |  | self ) |

long bytesAvailable | ( |  | self ) |

long bytesToWrite | ( |  | self ) |

[QSslCertificate] caCertificates | ( |  | self ) |

bool canReadLine | ( |  | self ) |

[KSslCipher] ciphers | ( |  | self ) |

close | ( |  | self ) |

connectToHost | ( | self, |
|  | QString | hostName,
|  | int | port,
|  | KTcpSocket.ProxyPolicy | policy=KTcpSocket.AutoProxy
| ) |  |  |

Take the hostname and port from url and connect to them. The information from a full URL enables the most accurate choice of proxy in case of proxy rules that depend on high-level information like protocol or username.

See also:
  KProtocolManager.proxyForUrl()

connectToHost | ( | self, |
|  | QHostAddress | hostAddress,
|  | int | port,
|  | KTcpSocket.ProxyPolicy | policy=KTcpSocket.AutoProxy
| ) |  |  |

Take the hostname and port from url and connect to them. The information from a full URL enables the most accurate choice of proxy in case of proxy rules that depend on high-level information like protocol or username.

See also:
  KProtocolManager.proxyForUrl()

connectToHost | ( | self, |
|  | KUrl | url,
|  | KTcpSocket.ProxyPolicy | policy=KTcpSocket.AutoProxy
| ) |  |  |

Take the hostname and port from url and connect to them. The information from a full URL enables the most accurate choice of proxy in case of proxy rules that depend on high-level information like protocol or username.

See also:
  KProtocolManager.proxyForUrl()

connectToHostEncrypted | ( | self, |
|  | QString | hostName,
|  | int | port,
|  | QIODevice.OpenMode | openMode=QIODevice.ReadWrite
| ) |  |  |

disconnectFromHost | ( |  | self ) |

KTcpSocket.EncryptionMode encryptionMode | ( |  | self ) |

KTcpSocket.Error error | ( |  | self ) |

bool flush | ( |  | self ) |

ignoreSslErrors | ( |  | self ) |

bool isSequential | ( |  | self ) |

bool isValid | ( |  | self ) |

QHostAddress localAddress | ( |  | self ) |

QSslCertificate localCertificate | ( |  | self ) |

KTcpSocket.SslVersion negotiatedSslVersion | ( |  | self ) |

QString negotiatedSslVersionName | ( |  | self ) |

bool open | ( | self, |
|  | QIODevice.OpenMode | open
| ) |  |  |

QHostAddress peerAddress | ( |  | self ) |

[QSslCertificate] peerCertificateChain | ( |  | self ) |

QString peerName | ( |  | self ) |

int peerPort | ( |  | self ) |

KSslKey privateKey | ( |  | self ) |

QNetworkProxy proxy | ( |  | self ) |

@see: connectToHost()

long readBufferSize | ( |  | self ) |

KSslCipher sessionCipher | ( |  | self ) |

setAdvertisedSslVersion | ( | self, |
|  | KTcpSocket.SslVersion | version
| ) |  |  |

setCaCertificates | ( | self, |
|  | [QSslCertificate] | certificates
| ) |  |  |

setCiphers | ( | self, |
|  | [KSslCipher] | ciphers
| ) |  |  |

setLocalCertificate | ( | self, |
|  | QSslCertificate | certificate
| ) |  |  |

setLocalCertificate | ( | self, |
|  | QString | fileName,
|  | QSsl.EncodingFormat | format=QSsl.Pem
| ) |  |  |

setPrivateKey | ( | self, |
|  | KSslKey | key
| ) |  |  |

setPrivateKey | ( | self, |
|  | QString | fileName,
|  | KSslKey.Algorithm | algorithm=KSslKey.Rsa,
|  | QSsl.EncodingFormat | format=QSsl.Pem,
|  | QByteArray | passPhrase=QByteArray()
| ) |  |  |

setProxy | ( | self, |
|  | QNetworkProxy | proxy
| ) |  |  |

@see: connectToHost()

setReadBufferSize | ( | self, |
|  | long | size
| ) |  |  |

setSocketOption | ( | self, |
|  | QAbstractSocket.SocketOption | options,
|  | QVariant | value
| ) |  |  |

Sets the socket option to value.

See also:
  QAbstractSocket.setSocketOption

Since:
  4.5.0

QVariant socketOption | ( | self, |
|  | QAbstractSocket.SocketOption | options
| ) |  |  |

Returns the state of the socket option.

See also:
  QAbstractSocket.socketOption

Since:
  4.5.0

[KSslError] sslErrors | ( |  | self ) |

startClientEncryption | ( |  | self ) |

KTcpSocket.State state | ( |  | self ) |

bool waitForBytesWritten | ( | self, |
|  | int | msecs
| ) |  |  |

bool waitForConnected | ( | self, |
|  | int | msecs=30000
| ) |  |  |

bool waitForDisconnected | ( | self, |
|  | int | msecs=30000
| ) |  |  |

bool waitForEncrypted | ( | self, |
|  | int | msecs=30000
| ) |  |  |

bool waitForReadyRead | ( | self, |
|  | int | msecs=30000
| ) |  |  |

## Enumeration Documentation

EncryptionMode

Enumerator:

  UnencryptedMode = 0 |
  SslClientMode |
  SslServerMode |

Error

Enumerator:

  UnknownError = 0 |
  ConnectionRefusedError |
  RemoteHostClosedError |
  HostNotFoundError |
  SocketAccessError |
  SocketResourceError |
  SocketTimeoutError |
  NetworkError |
  UnsupportedSocketOperationError |

ProxyPolicy

Enumerator:

  AutoProxy = 0 |
  ManualProxy |

SslVersion

Enumerator:

  UnknownSslVersion = 0x01 |
  SslV2 = 0x02 |
  SslV3 = 0x04 |
  TlsV1 = 0x08 |
  SslV3_1 = 0x08 |
  AnySslVersion = SslV2|SslV3|TlsV1 |

State

Enumerator:

  UnconnectedState = 0 |
  HostLookupState |
  ConnectingState |
  ConnectedState |
  BoundState |
  ListeningState |
  ClosingState |