Module: anynet.util

Provides useful functions that didn't fit into another module.

StreamError: tuple = ( anyio.EndOfStream, anyio.ClosedResourceError, anyio.BrokenResourceError )

def is_decimal(s: str) -> bool
Returns True if s is non-empty and only contains decimal digits.

def is_hexadecimal(s: str) -> bool
Returns True if s is non-empty and only contains hexadecimal digits.

def ip_to_hex(ip: str) -> int
Converts an IPv4 address string to an integer in big-endian byte order. Raises ValueError if the IP address is invalid.

def ip_from_hex(value: int) -> str
Converts an integer to an IPv4 address string in big-endian byte order.

def local_address() -> str
Returns the local IPv4 address of the default gateway.

def broadcast_address() -> str
Returns the IPv4 broadcast address of the default gateway.

def parse_url(url: str) -> tuple[str, str, int, str]
Parses the given URL and returns the tuple (scheme, host, port, path). The scheme, port and path are set to None if they are not in the URL. Raises ValueError if the URL is invalid.

def make_url(scheme: str, host: str, port: int, path: str) -> str
Creates a URL string from the given parameters. scheme, port and path may be set to None.

async with create_task_group() -> anyio.abc.TaskGroup
Creates a task group that is cancelled if the end of the async with block is reached.