COTP

Python implementation

Connection oriented transport protocol

hat.drivers.cotp.mlog

module logger

Type

logging.Logger

hat.drivers.cotp.Data

Data

alias of Union[bytes, bytearray, memoryview]

class hat.drivers.cotp.Address(host, port)

Bases: tuple

Create new instance of Address(host, port)

host

host name

Type

str

port

TCP port

Type

int

class hat.drivers.cotp.ConnectionInfo(local_addr, local_tsel, remote_addr, remote_tsel)

Bases: tuple

Create new instance of ConnectionInfo(local_addr, local_tsel, remote_addr, remote_tsel)

local_addr

local address

Type

Address

local_tsel

local COTP selector

Type

Optional[int]

remote_addr

remote address

Type

Address

remote_tsel

remote COTP selector

Type

Optional[int]

hat.drivers.cotp.ConnectionCb

Connection callback

alias of Callable[[Connection], Union[None, Awaitable[None]]]

async hat.drivers.cotp.connect(addr, local_tsel=None, remote_tsel=None)

Create new COTP connection

Parameters
  • addr (Address) – remote address

  • local_tsel (Optional[int]) – local COTP selector

  • remote_tsel (Optional[int]) – remote COTP selector

Returns

Connection

async hat.drivers.cotp.listen(connection_cb, addr=Address(host='0.0.0.0', port=102))

Create new COTP listening server

Parameters
  • connection_cb (ConnectionCb) – new connection callback

  • addr (Address) – local listening address

Returns

Server

class hat.drivers.cotp.Server

Bases: object

COTP listening server

For creation of new instance see listen()

property addresses

listening addresses

Type

List[Address]

property closed

closed future

Type

asyncio.Future

async async_close()

Close listening socket

Calling this method doesn’t close active incomming connections

class hat.drivers.cotp.Connection

Bases: object

COTP connection

For creation of new instance see connect()

property info

connection info

Type

ConnectionInfo

property closed

closed future

Type

asyncio.Future

async async_close()

Async close

async read()

Read data

Returns

Data

write(data)

Write data

Parameters

data (bytes) – data