Skip to content

port1900.client

Async Nex protocol client implementation.

DEFAULT_TIMEOUT module-attribute

DEFAULT_TIMEOUT: Final[float] = 30.0

Default timeout in seconds for Nex network operations.

Client

Client(
    *,
    timeout: float | None = DEFAULT_TIMEOUT,
    encoding: str = "utf-8",
)

An asynchronous client for the Nex protocol.

Parameters:

Name Type Description Default

timeout

float | None

Default timeout in seconds for requests, or None for no timeout.

DEFAULT_TIMEOUT

encoding

str

Default character encoding for response text.

'utf-8'

encoding property

encoding: str

The default character encoding for decoding responses.

timeout property

timeout: float | None

The default timeout in seconds for requests.

get async

get(
    target: str | NexURI,
    *,
    timeout: float | None = None,
    encoding: str | None = None,
) -> Response

Alias for request.

request async

request(
    target: str | NexURI,
    *,
    timeout: float | None = None,
    encoding: str | None = None,
) -> Response

Send a Nex request to a server.

Parameters:

Name Type Description Default

target

str | NexURI

Either a Nex target string (e.g. 'nex://example.com/hello.txt') or a NexURI.

required

timeout

float | None

Optional timeout override in seconds for this request.

None

encoding

str | None

Optional character encoding override for decoding the response.

None

Returns:

Type Description
Response

A Response instance containing the server output and URI metadata.

Raises:

Type Description
URIError

If the target string cannot be parsed as a valid Nex URI.

ConnectionError

If network connection to the server fails.

TimeoutError

If the request times out.