aio_adb_shell.handle.tcp_handle module

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

class aio_adb_shell.handle.tcp_handle.TcpHandle(host, port=5555, default_timeout_s=None)[source]

Bases: aio_adb_shell.handle.base_handle.BaseHandle

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)

  • default_timeout_s (float, None) – Default timeout in seconds for TCP packets, or None

_default_timeout_s

Default timeout in seconds for TCP packets, or None

Type

float, None

_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

TODO

Type

StreamReader, None

_writer

TODO

Type

StreamWriter, None

_abc_impl = <_abc_data object>
async bulk_read(numbytes, timeout_s=None)[source]

Receive data from the socket.

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

  • timeout_s (float, None) – When the timeout argument is omitted, select.select blocks until at least one file descriptor is ready. A time-out value of zero specifies a poll and never blocks.

Returns

The received data

Return type

bytes

Raises

TcpTimeoutException – Reading timed out.

async bulk_write(data, timeout_s=None)[source]

Send data to the socket.

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

  • timeout_s (float, None) – When the timeout argument is omitted, select.select blocks until at least one file descriptor is ready. A time-out value of zero specifies a poll and never blocks.

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(timeout_s=None)[source]

Create a socket connection to the device.

Parameters

timeout_s (float, None) – Set the timeout on the socket instance