Telnet 0.10.2

.NET 6.0 .NET Standard 2.0 .NET Framework 4.6.2
There is a newer version of this package available.
See the version list below for details.
dotnet add package Telnet --version 0.10.2
NuGet\Install-Package Telnet -Version 0.10.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Telnet" Version="0.10.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Telnet --version 0.10.2
#r "nuget: Telnet, 0.10.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Telnet as a Cake Addin
#addin nuget:?package=Telnet&version=0.10.2

// Install Telnet as a Cake Tool
#tool nuget:?package=Telnet&version=0.10.2

Build, Publish, Tag


We needed to issue simple commands to (and monitor) a router remotely and that's what we've been able to achieve with this little library. It's usage is simple, it doesn't do anything particularly fancy but if all you're wanting to do is interact with a telnet server by issuing commands, parsing text responses and having the opportunity to respond in code accordingly then hopefully having taken the time to wrap this up in a simple NuGet package will make your life easier!

FWIW I'm happy to take merge requests if they meet incumbent standards, don't break anything and accomodate the code file sharing so all versions work (and likely receive the same change). I'm no TCPIP/Telnet expert but if I can help out with bugs or feature requests I'll do what I can, outside my day job ofc!

v0.9 introduced a significant bump to Net versions and some potentially breaking code changes. Changes to your consuming code should be minimal, but be prepared to test thoroughly. Please raise an Issue if you encounter any problems; in part it'll help others with the same problems and we'll see what we can do to accomodate your use cases.


    //Sync Example
    namespace PrimS.Telnet.CiTests
      using FluentAssertions;
      using Xunit;
      using System;
      using System.Text.RegularExpressions;

      public class ReadMeExampleFixture
        private const int TimeoutMs = 5000;

        public void ReadMeExample()
          using (TelnetServer server = new TelnetServer())
            using (Client client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
              Client.IsWriteConsole = true;
              client.TryLogin("username", "password", TimeoutMs).Should().Be(true);
              client.WriteLine("show statistic wan2");
              string s = client.TerminatedRead(">", TimeSpan.FromMilliseconds(TimeoutMs));
              Regex regEx = new Regex("(?!WAN2 total TX: )([0-9.]*)(?! GB ,RX: )([0-9.]*)(?= GB)");
              MatchCollection matches = regEx.Matches(s);
              decimal tx = decimal.Parse(matches[0].Value);
              decimal rx = decimal.Parse(matches[1].Value);
              (tx + rx).Should().BeGreaterThan(0);
              (tx + rx).Should().BeLessThan(50);
    // Async Example
    namespace PrimS.Telnet.CiTests
      using System;
      using FluentAssertions;
      using System.Threading.Tasks;
      using System.Text.RegularExpressions;
      using Xunit;

      public class ReadMeExampleFixture
        public const string Pattern = "(?:WAN2 total TX: )([0-9.]*) ((?:[KMG]B)|(?:Bytes))(?:[, ]*RX: )([0-9.]*) ((?:[KMG]B)|(?:Bytes))";
        private const int TimeoutMs = 5000;

        public async Task ReadMeExample()
          using (var server = new DummyTelnetServer())
            using (var client = new Client(server.IPAddress.ToString(), server.Port, new System.Threading.CancellationToken()))
              Client.IsWriteConsole = false;
              (await client.TryLoginAsync("username", "password", TimeoutMs)).Should().Be(true);
              await client.WriteLineAsync("show statistic wan2");
              string s = await client.TerminatedReadAsync(">", TimeSpan.FromMilliseconds(TimeoutMs));
              var regEx = new Regex(Pattern);
              MatchCollection matches = regEx.Matches(s);
              matches[0].Groups[0].Value.Should().Be("WAN2 total TX: 6.3 GB ,RX: 6.9 GB");
    // VB.NET Example
    Private Async Function RunRemoteScript(commandLine As String) As Task(Of Boolean)
        Using telnet = New Client("HostName", 23, _cancellationSource.Token)
            If Not telnet.IsConnected Then Return False
            Dim loggedOn = Await telnet.TryLoginAsync("username", "password", SocketTimeout, "#"))
            If Not loggedOn Then Return False
            Await telnet.WriteLine(commandLine)
            Dim serverResponse = Await telnet.TerminatedReadAsync("#", TimeSpan.FromMilliseconds(SocketTimeout))
            Await telnet.WriteLine("exit")
            Dim logoutMessage = Await telnet.ReadAsync(New TimeSpan(100))
        End Using
        Return True  ' If we got this far; celebrate
    End Function
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Telnet:

Package Downloads

Collect metrics from your TeamSpeak 3 Server


sensor aggregator


A .Net HEOS CLI client using Reactive Extensions

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.11.3 2,381 9/17/2022
0.11.2 996 9/3/2022
0.11.1 244 9/2/2022
0.11.0 291 9/2/2022
0.10.2 778 8/22/2022
0.10.1 248 8/21/2022
0.10.0 123 8/20/2022
0.9.1 513 8/18/2022
0.9.0-beta0001 7,081 5/16/2018
0.8.6 125,684 9/3/2020
0.8.6-beta0001 322 9/2/2020
0.8.4 39,686 10/9/2019
0.8.3 24,186 3/7/2019
0.8.2 3,217 1/30/2019
0.8.1 57,812 5/8/2018
0.8.0 29,595 3/12/2017
0.7.0 9,684 9/6/2016
0.6.1 51,884 2/25/2016
0.6.0 1,374 1/27/2016
0.5.0 1,375 12/8/2015
0.4.0 1,819 10/27/2015
0.3.2 1,334 9/15/2015
0.3.1 2,203 6/20/2015
0.2.5 59,263 12/15/2014
0.2.0 1,153 11/27/2014
0.1.0 1,297 11/26/2014

Building on 0.9.1 which introduced potentially breaking changes and dropped unsupported Net
     versions Std1.6, 3.5, 4.0, 4.5.1 (all sync) while adding 4.6.2 (sync), NetStandard 4.7.2,
     4.8 and Std2.1 (all async) this release additionally adds Net6.

     Note the constructor Client(IByteStream byteStream, TimeSpan timeout, CancellationToken token)
     has been reordered to comply with best practice standards.

     Lots of rework was needed on the async chains to properly integrate 0.9.1 changes, and the
     equivalent functionality introduced has now been replicated on the sync paths as well. Test
     coverage has been extended to cover both; which actually revealed some unintended code... that
     has been rectified in this release.