ctelnet 0.3.1 copy "ctelnet: ^0.3.1" to clipboard
ctelnet: ^0.3.1 copied to clipboard

A simple Telnet client for Dart/Flutter, parse incoming and outgoing data easily and quickly.

example/example.dart

import 'dart:io';

import 'package:ctelnet/ctelnet.dart';

var env = Platform.environment;
final host = env['HOST'] ?? 'localhost';
final port = int.parse(env['PORT'] ?? '23');

void main(List<String> args) async {
  print('Connecting to $host:$port');

  final client = CTelnetClient(
    host: host,
    port: port,
    timeout: Duration(seconds: 30),
    onConnect: () => print('Connected'),
    onDisconnect: () => print('Disconnected'),
    onError: (error) => print('Error: $error'),
  );

  final sub = await client.connect();

  if (sub == null) {
    throw Exception('Failed to connect');
  }

  // listen to the stream of messages
  sub.listen((data) {
    print('Message received!');
    print('text:      ${data.text}');
    print('Debug:     ${data.toDebugString()}');
    print('Colored: ${data.coloredText.map((t) => t.formatted).join('')}');
    print('');
  });

  // send a message
  client.send('Hello, world!');

  // send a command
  client.doo(Symbols.compression2);

  await Future.delayed(Duration(seconds: 5));

  await client.disconnect();
}
3
likes
160
points
101
downloads

Publisher

verified publishercasraf.dev

Weekly Downloads

A simple Telnet client for Dart/Flutter, parse incoming and outgoing data easily and quickly.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

terminal_color_parser

More

Packages that depend on ctelnet