using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp.TelnetSamples { internal class AsyncTelnetConsole { private static IAsyncTelnetClient _client; public AsyncTelnetConsole(IAsyncTelnetClient client) { _client = client; } public void Start(string ip, int port = 23) { try { _client.MessageCallback += On_Receive; _client.Connect(ip, port); while (true) { string command = Console.ReadLine(); if (command == "quit" || command == "exit") break; _client.SendCommand(command); } } catch (Exception) { throw; } } private void On_Receive(object? sender, string e) { Console.Write(e); } } }