Module provides class BaseClient.

class BaseClient(shell=None, log=None, loop=None, encoding='utf8', encoding_errors='strict', force_binary=False, connect_minwait=1.0, connect_maxwait=4.0, limit=None, waiter_closed=None, _waiter_connected=None)

Bases: asyncio.streams.FlowControlMixin, asyncio.protocols.Protocol

Base Telnet Client Protocol.

Class initializer.


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().


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.
Returns:Whether negotiation is over (client end is satisfied).
Return type:bool

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

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.


Called when the connection is lost or closed.

Parameters:exc (Exception) – exception. None indicates a closing EOF sent by this end.

Called when a connection is made.

Sets attributes _transport, _when_connected, _last_received, reader and writer.

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


Process bytes received by transport.


Time elapsed since client connected, in seconds as float.

encoding(outgoing=False, incoming=False)

Encoding that should be used for the direction indicated.

The base implementation always returns default_encoding or, when unspecified, US-ASCII.


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

get_extra_info(name, default=None)

Get optional client protocol or transport information.


Time elapsed since data last received, in seconds as float.