{"id":4275,"library":"telnetlib3","title":"telnetlib3: Async Telnet Server and Client","description":"telnetlib3 is an asynchronous Python library for building Telnet servers and clients, supporting a wide array of Telnet Option specifications (RFCs). It offers both a programmatic API and command-line utilities. Currently at version 4.0.2, it maintains an active release cadence with frequent bug fixes and feature enhancements.","status":"active","version":"4.0.2","language":"python","source_language":"en","source_url":"https://github.com/jquast/telnetlib3","tags":["network","telnet","async","client","server","protocol"],"install":[{"cmd":"pip install telnetlib3","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"Primary library import, allows access to all functions via `telnetlib3.<function>`.","symbol":"telnetlib3","correct":"import telnetlib3"},{"note":"Direct import for creating a Telnet server.","symbol":"create_server","correct":"from telnetlib3 import create_server"},{"note":"Direct import for establishing a Telnet client connection.","symbol":"open_connection","correct":"from telnetlib3 import open_connection"}],"quickstart":{"code":"import telnetlib3\nimport asyncio\nimport os\n\nasync def simple_shell(reader, writer):\n    peername = writer.get_extra_info('peername')\n    print(f'Client {peername} connected.')\n    writer.write(f'Hello, {peername}! Type something and press Enter (or Ctrl+C to quit).\r\n')\n    while True:\n        try:\n            text = await reader.read(1024)\n            if not text:\n                break\n            print(f'Received from {peername}: {text!r}')\n            writer.write(f'You said: {text!r}\r\n')\n            await writer.drain()\n        except asyncio.IncompleteReadError:\n            break # Client disconnected\n        except ConnectionResetError:\n            break # Client forcibly closed\n\n    print(f'Client {peername} disconnected.')\n\nasync def main():\n    # Use os.environ for port to make it runnable without hardcoding\n    port = int(os.environ.get('TELNET_PORT', '6023'))\n    server = await telnetlib3.create_server(port=port, shell=simple_shell)\n    print(f\"Telnet server listening on port {port}\")\n    async with server:\n        await server.serve_forever()\n\nif __name__ == '__main__':\n    try:\n        asyncio.run(main())\n    except KeyboardInterrupt:\n        print(\"Server stopped gracefully.\")\n","lang":"python","description":"This quickstart demonstrates a basic Telnet server using `telnetlib3`. It sets up an asynchronous server that echoes back any text received from connected clients. The server listens on port 6023 by default, or a port specified by the `TELNET_PORT` environment variable. To test, run this script and then connect with `telnet localhost 6023` in another terminal."},"warnings":[{"fix":"Remove imports and usage of `telnetlib3.color_filter`. Consider migrating color filtering logic to a separate utility or `Telix` library if similar functionality is needed.","message":"The `color_filter` module was removed. Any code directly importing or using this module will break.","severity":"breaking","affected_versions":">=4.0.1"},{"fix":"For the client, use the `--line-mode` CLI option to restore line-buffered behavior. For the server's PTY execution, use `--line-mode` with `--pty-exec` to restore cooked PTY mode with echo.","message":"The default operating mode for `telnetlib3-client` (CLI) and `telnetlib3-server --pty-exec` (CLI) changed from line-buffered local echo to raw terminal mode (no line buffering, no local echo). This significantly alters user interaction.","severity":"breaking","affected_versions":">=2.5.0"},{"fix":"If your application relies on a minimum wait time for negotiation (e.g., for specific legacy clients/servers), explicitly set `connect_minwait=1.0` (or your desired value) when calling `open_connection()` or `create_server()`.","message":"The default value for the `connect_minwait` parameter in `open_connection()` and `create_server()` was changed from 1.0 seconds to 0 seconds. This affects how long the library waits before performing initial negotiation.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade to `telnetlib3` version 4.0.2 or newer. The client now automatically detects zlib/gzip format and falls back to raw deflate as needed, resolving these decompression issues.","message":"Prior to version 4.0.2, MCCP2 decompression could fail on some MUD servers using raw deflate or gzip-wrapped compression, leading to garbled banners or corrupted data.","severity":"gotcha","affected_versions":"<4.0.2"}],"env_vars":null,"search_vec":"'4.0.2':42 'activ':46 'api':33 'array':22 'async':2,58 'asynchron':10 'bug':51 'build':14 'cadenc':48 'client':6,18,59 'command':36 'command-lin':35 'current':39 'enhanc':55 'featur':54 'fix':52 'frequent':50 'librari':12 'line':37 'maintain':44 'network':56 'offer':29 'option':25 'programmat':32 'protocol':61 'python':11 'releas':47 'rfcs':27 'server':4,16,60 'specif':26 'support':19 'telnet':3,15,24,57 'telnetlib3':1,7 'util':38 'version':41 'wide':21","created_at":"2026-04-12T03:48:24.870499+00:00","updated_at":"2026-04-12T03:48:24.870499+00:00","problems":[],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"5.0.0","cli_name":"telnet","cli_version":"sh: 1: telnet: not found","type":"library","homepage":null,"github":"https://github.com/jquast/telnetlib3","docs":"https://telnetlib3.readthedocs.io","changelog":null,"pypi":"https://pypi.org/project/telnetlib3/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}