adb_shell.transport.tcp_transport_async module

A class for creating a socket connection with the device and sending and receiving data.

class adb_shell.transport.tcp_transport_async.TcpTransportAsync(host, port=5555)[source]

Bases: BaseTransportAsync

TCP connection object.

Parameters:
  • host (str) – The address of the device; may be an IP address or a host name

  • port (int) – The device port to which we are connecting (default is 5555)

_host

The address of the device; may be an IP address or a host name

Type:

str

_port

The device port to which we are connecting (default is 5555)

Type:

int

_reader

Object for reading data from the socket

Type:

StreamReader, None

_writer

Object for writing data to the socket

Type:

StreamWriter, None

_abc_impl = <_abc._abc_data object>
async bulk_read(numbytes, transport_timeout_s)[source]

Receive data from the socket.

Parameters:
  • numbytes (int) – The maximum amount of data to be received

  • transport_timeout_s (float, None) – Timeout for reading data from the socket; if it is None, then it will block until the read operation completes

Returns:

The received data

Return type:

bytes

Raises:

TcpTimeoutException – Reading timed out.

async bulk_write(data, transport_timeout_s)[source]

Send data to the socket.

Parameters:
  • data (bytes) – The data to be sent

  • transport_timeout_s (float, None) – Timeout for writing data to the socket; if it is None, then it will block until the write operation completes

Returns:

The number of bytes sent

Return type:

int

Raises:

TcpTimeoutException – Sending data timed out. No data was sent.

async close()[source]

Close the socket connection.

async connect(transport_timeout_s)[source]

Create a socket connection to the device.

Parameters:

transport_timeout_s (float, None) – Timeout for connecting to the socket; if it is None, then it will block until the operation completes