client_base

Module provides class BaseClient.

class BaseClient(shell=None, encoding='utf8', encoding_errors='strict', force_binary=False, connect_minwait=0, connect_maxwait=4.0, limit=None, waiter_closed=None, _waiter_connected=None)[source]

Base Telnet Client Protocol.

Class initializer.

default_encoding

encoding for new connections

connect_minwait

minimum duration for check_negotiation().

connect_maxwait

maximum duration for check_negotiation().

eof_received()[source]

Called when the other end calls write_eof() or equivalent.

Return type:

None

connection_lost(exc)[source]

Called when the connection is lost or closed.

Parameters:

exc (Optional[Exception]) – Exception instance, or None to indicate a closing EOF sent by this end.

Return type:

None

connection_made(transport)[source]

Called when a connection is made.

Ensure super().connection_made(transport) is called when derived.

Return type:

None

begin_shell(future)[source]

Start the shell coroutine after negotiation completes.

Return type:

None

data_received(data)[source]

Process bytes received by transport.

Buffer incoming data and schedule async processing to keep the event loop responsive. Apply read-side backpressure using transport.pause_reading()/resume_reading().

Return type:

None

begin_negotiation()[source]

Begin on-connect negotiation.

A Telnet client is expected to send only a minimal amount of client session options immediately after connection, it is generally the server which dictates server option support.

Deriving implementations should always call super().begin_negotiation().

Return type:

None

encoding(outgoing=False, incoming=False)[source]

Encoding that should be used for the direction indicated.

The base implementation always returns encoding argument given to class initializer or, when unset (None), US-ASCII.

Return type:

Union[str, bool]

check_negotiation(final=False)[source]

Callback, return whether negotiation is complete.

Parameters:

final (bool) – Whether this is the final time this callback will be requested to answer regarding protocol negotiation.

Return type:

bool

Returns:

Whether negotiation is over (client end is satisfied).

Method is called on each new command byte processed until negotiation is considered final, or after connect_maxwait has elapsed, setting the _waiter_connected attribute to value self when complete.

If critical negotiations have completed (TTYPE and either NEW_ENVIRON or CHARSET), negotiation is considered complete immediately without waiting for connect_minwait. Otherwise, this method returns False until connect_minwait has elapsed, ensuring the server may batch telnet negotiation demands without prematurely entering the callback shell.

Ensure super().check_negotiation() is called and conditionally combined when derived.