the overall lack of documentation for the server part led me to try the example code verbatim. The snippet completes, instead of waiting for a connection.
import asyncio, telnetlib3
async def shell(reader, writer):
writer.write('\r\nWould you like to play a game? ')
inp = await reader.read(1)
if inp:
writer.echo(inp)
writer.write('\r\nThey say the only way to win '
'is to not play at all.\r\n')
await writer.drain()
writer.close()
loop = asyncio.get_event_loop()
coro = telnetlib3.create_server('127.0.0.1', 6023, shell=shell)
server = loop.run_until_complete(coro)
loop.run_until_complete(server.wait_closed())
results in
/home/anton/PycharmProjects/XO/venv/PycharmProjects/bin/python /home/anton/.config/JetBrains/PyCharmCE2023.2/scratches/scratch.py
/home/anton/.config/JetBrains/PyCharmCE2023.2/scratches/scratch.py:13: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
Process finished with exit code 0
The internet is full of telnet client examples of usage of this library, but no telnet server.
the overall lack of documentation for the server part led me to try the example code verbatim. The snippet completes, instead of waiting for a connection.
results in
The internet is full of telnet client examples of usage of this library, but no telnet server.