{"id":21261537,"url":"https://github.com/chenasraf/ctelnet_dart","last_synced_at":"2025-10-11T20:45:17.995Z","repository":{"id":230305994,"uuid":"694384706","full_name":"chenasraf/ctelnet_dart","owner":"chenasraf","description":"A telnet client written in Dart","archived":false,"fork":false,"pushed_at":"2024-04-09T11:35:51.000Z","size":50,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T22:11:24.274Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/ctelnet","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenasraf.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"chenasraf","patreon":null,"open_collective":null,"ko_fi":"casraf","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=TSH3C3ABGQM22\u0026currency_code=ILS\u0026source=url"]}},"created_at":"2023-09-20T22:34:29.000Z","updated_at":"2024-11-13T10:35:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"e41fc44b-cc35-4f0c-b9ce-e7da45a540b2","html_url":"https://github.com/chenasraf/ctelnet_dart","commit_stats":null,"previous_names":["chenasraf/ctelnet_dart"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenasraf%2Fctelnet_dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenasraf%2Fctelnet_dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenasraf%2Fctelnet_dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenasraf%2Fctelnet_dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenasraf","download_url":"https://codeload.github.com/chenasraf/ctelnet_dart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243695589,"owners_count":20332629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T04:43:42.090Z","updated_at":"2025-10-11T20:45:12.942Z","avatar_url":"https://github.com/chenasraf.png","language":"Dart","funding_links":["https://github.com/sponsors/chenasraf","https://ko-fi.com/casraf","https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=TSH3C3ABGQM22\u0026currency_code=ILS\u0026source=url","https://ko-fi.com/casraf'"],"categories":[],"sub_categories":[],"readme":"# CTelnet\n\nThis package is a telnet client implementation in dart. You can connect to a telnet server, and get\nand send data in a simple interface.\n\n## Features\n\n- Parses data for easy querying\n- Supports sending \u0026 receiving options and subnegotiations\n- Works in plain Dart or Flutter environments\n\n## Getting started\n\nThere are no prerequisites to using this package. Simply add it to your pubspec, and import the\nclient to be used.\n\n```sh\ndart pub add ctelnet\n# or\nflutter pub add ctelnet\n```\n\nAll you normally need to import is in the main `ctelnet.dart` file:\n\n```dart\nimport 'package:ctelnet/ctelnet.dart'\n```\n\n## Usage\n\n### Connecting to a server\n\nJust use `CTelnetClient` to connect. You first initialize it, then connect when you are ready.\n\n```dart\nFuture\u003cvoid\u003e connect(String host, int port) {\n  print('Connecting to $host:$port');\n\n  final client = CTelnetClient(\n    host: host,\n    port: port,\n    timeout: Duration(seconds: 30),\n    onConnect: () =\u003e print('Connected'),\n    onDisconnect: () =\u003e print('Disconnected'),\n    onError: (error) =\u003e print('Error: $error'),\n  );\n\n  final stream = await client.connect();\n  final subscription = stream.listen((data) =\u003e print('Data received: ${data.text}'));\n}\n```\n\n### Sending data to server\n\nTo send data to the server, you can use the `send` and `sendBytes` methods on the client.\n\nThe method `send` will let you send any plaintext, which should be fine for most cases, but you may\nsend any raw information using `sendBytes` and supplying a byte array.\n\nThere are also built-in methods for sending commands to the telnet server, such as the `will`,\n`wont`, `doo` and `dont` methods for handling telnet options.\n\n```dart\nconst MCCP2 = 86;\n\nvoid sendExamples() {\n  // Send a string\n  client.send('Hello, world');\n\n  // Send raw bytes\n  client.sendBytes([Symbols.iac, Symbols.sb] + 'Hello, world!'.codeUnits);\n\n  // Send commands\n  client.doo(Symbols.compression2);\n}\n```\n\nYou can see more methods in the documentation for the `CTelnetClient` object.\n\n### Receiving data from server\n\nYou can also use parsed or raw information for received `Message` objects.\n\n```dart\nfinal stream = await client.connect();\nfinal subscription = stream.listen(handleMessage);\n\nbool isEncrypted = false;\n\nvoid handleMessage(Message msg) {\n  if (msg.will(Symbols.compression2)) {\n    client.doo(Symbols.compression2)\n  }\n\n  if (msg.sb(Symbols.compression2)) {\n    isEncrypted = true;\n    /// proceed to process data\n  }\n\n  print('The plaintext portion of the message is: ${msg.text}');\n  print('The attached commands are: ${msg.commands}');\n}\n```\n\nYou can see more methods in the documentation for the `Message` object.\n\n### Using ANSI/xterm colors\n\nCTelnet comes with a built-in ANSI/xterm color parser. You can get the list of colored segments\ninside a message object using the `coloredText` property:\n\n```dart\nvoid handleMessage(Message msg) {\n  for (final segment in msg.coloredText) {\n    print('Uncolored: ${segment.text}');\n    print('Foreground: ${segment.fgColor}');\n    print('Background: ${segment.bgColor}');\n    print('Colored for terminal: ${segment.formatted}');\n  }\n}\n```\n\n## Contributing\n\nI am developing this package on my free time, so any support, whether code, issues, or just stars is\nvery helpful to sustaining its life. If you are feeling incredibly generous and would like to donate\njust a small amount to help sustain this project, I would be very very thankful!\n\n\u003ca href='https://ko-fi.com/casraf' target='_blank'\u003e\n  \u003cimg height='36' style='border:0px;height:36px;'\n    src='https://cdn.ko-fi.com/cdn/kofi1.png?v=3'\n    alt='Buy Me a Coffee at ko-fi.com' /\u003e\n\u003c/a\u003e\n\nI welcome any issues or pull requests on GitHub. If you find a bug, or would like a new feature,\ndon't hesitate to open an appropriate issue and I will do my best to reply promptly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenasraf%2Fctelnet_dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenasraf%2Fctelnet_dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenasraf%2Fctelnet_dart/lists"}