UDP

Python implementation

Asyncio UDP endpoint wrapper

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

Bases: tuple

Create new instance of Address(host, port)

host

str

port

int

async hat.drivers.udp.create(local_addr=None, remote_addr=None, queue_size=0, **kwargs)

Create new UDP endpoint

Parameters
  • local_addr (Optional[Address]) – local address

  • remote_addr (Optional[Address]) – remote address

  • queue_size (int) – receive queue max size

  • kwargs – additional arguments passed to asyncio.AbstractEventLoop.create_datagram_endpoint()

Returns

Endpoint

class hat.drivers.udp.Endpoint

Bases: object

UDP endpoint

property closed

closed future

Type

asyncio.Future

property empty

is receive queue empty

Type

bool

async async_close()

Async close

send(data, remote_addr=None)

Send datagram

If remote_addr is not set, remote_addr passed to create() is used.

Parameters
  • data (bytes) – data

  • remote_addr (Optional[Address]) – address

async receive()

Receive datagram

Returns

Tuple[bytes,Address]