Package: asynctelnet
Introductionasynctelnet is an asynchronous Telnet Client and Server library for python.
This project requires python 3.6 and later, using theanyiomodule.asynctelnet is a heavily modified anyio-ization of thetelnetlib3module.Quick ExampleAuthoring a Telnet Server using Streams interface that offers a basic war game:importanyio,asynctelnetasyncdefshell(tcp):asyncwithasynctelnet.TelnetServer(tcp)asstream:# this will fail if no charset has been negotiatedawaitstream.send('\r\nWould you like to play a game? ')inp=awaitreader.receive(1)ifinp:awaitstream.echo(inp)awaitstream.send('\r\nThey say the only way to win ''is to not play at all.\r\n')asyncdefmain():listener=awaitanyio.create_tcp_listener(local_port=56023)awaitlistener.serve(shell)anyio.run(main)Authoring a Telnet Client that plays the war game with this server:importanyio,asynctelnetasyncdefshell(tcp):asyncwithasynctelnet.TelnetClient(tcp,client=True)asstream:whileTrue:# read stream until '?' mark is foundoutp=awaitstream.receive(1024)ifnotoutp:# End of Filebreakelif'?'inoutp:# reply all questions with 'y'.awaitstream.send('y')# display all server outputprint(outp,flush=True)# EOFprint()asyncdefmain():asyncwithawaitconnect_tcp('localhost',56023)asclient:awaitshell(client)anyio.run(main)Command LineTwo command line scripts are distributed with this package.asynctelnet-clientSmall terminal telnet client.  Some example destinations and options:asynctelnet-client nethack.alt.org
asynctelnet-client --encoding=cp437 --force-binary blackflag.acid.org
asynctelnet-client htc.zapto.orgasynctelnet-serverTelnet server providing the default debugging shell.  This provides a simple
shell server that allows introspection of the session’s values, for example:tel:sh> help
quit, writer, slc, toggle [option|all], reader, proto

tel:sh> writer
<TelnetWriter server mode:kludge +lineflow -xon_any +slc_sim server-will:BINARY,ECHO,SGA client-will:BINARY,NAWS,NEW_ENVIRON,TTYPE>

tel:sh> reader
<TelnetReaderUnicode encoding='utf8' limit=65536 buflen=0 eof=False>

tel:sh> toggle all
wont echo.
wont suppress go-ahead.
wont outbinary.
dont inbinary.
xon-any enabled.
lineflow disabled.

tel:sh> reader
<TelnetReaderUnicode encoding='US-ASCII' limit=65536 buflen=1 eof=False>

tel:sh> writer
<TelnetWriter server mode:local -lineflow +xon_any +slc_sim client-will:NAWS,NEW_ENVIRON,TTYPE>Both command-line scripts accept argument--shell=my_module.fn_shelldescribing a python module path to a coroutine of signatureshell(reader, writer), just as the above examples.FeaturesThe following RFC specifications are implemented:rfc-727, “Telnet Logout Option,” Apr 1977.rfc-779, “Telnet Send-Location Option”, Apr 1981.rfc-854, “Telnet Protocol Specification”, May 1983.rfc-855, “Telnet Option Specifications”, May 1983.rfc-856, “Telnet Binary Transmission”, May 1983.rfc-857, “Telnet Echo Option”, May 1983.rfc-858, “Telnet Suppress Go Ahead Option”, May 1983.rfc-859, “Telnet Status Option”, May 1983.rfc-860, “Telnet Timing mark Option”, May 1983.rfc-885, “Telnet End of Record Option”, Dec 1983.rfc-1073, “Telnet Window Size Option”, Oct 1988.rfc-1079, “Telnet Terminal Speed Option”, Dec 1988.rfc-1091, “Telnet Terminal-Type Option”, Feb 1989.rfc-1096, “Telnet X Display Location Option”, Mar 1989.rfc-1123, “Requirements for Internet Hosts”, Oct 1989.rfc-1184, “Telnet Linemode Option (extended options)”, Oct 1990.rfc-1372, “Telnet Remote Flow Control Option”, Oct 1992.rfc-1408, “Telnet Environment Option”, Jan 1993.rfc-1571, “Telnet Environment Option Interoperability Issues”, Jan 1994.rfc-1572, “Telnet Environment Option”, Jan 1994.rfc-2066, “Telnet Charset Option”, Jan 1997.Further ReadingFurther documentation available athttps://asynctelnet.readthedocs.org/