9swampy / Telnet

Published on Nuget at https://www.nuget.org/packages/Telnet

Home Page:http://www.nugetmusthaves.com/Package/Telnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read string always empty in passive mode

lshender opened this issue · comments

I am trying to use Telnet client against Altusen PKVM. While my code obviously succeeds to power the PKVM outlet off and on via telnet, I can not read the state of the device because the string read from client is always empty. Maybe it's because of the passive mode of communication? Using PuTTY, I have to set the communication mode to passive, otherwise I don't see a thing.

This is my code:

using (Client clientTelnetPkvm = new Client(PkvmHost,
                PkvmPort,
                new CancellationToken()))
{
    if (!clientTelnetPkvm.IsConnected)
        throw new Exception(
            string.Format("Cannot connect to telnet on PKVM at {0}:{1}", PkvmHost, PkvmPort));

    clientTelnetPkvm.TerminatedRead("Login:", PkvmReadTimeout);
    clientTelnetPkvm.WriteLine(PkvmUsername);
    clientTelnetPkvm.TerminatedRead("Password:", PkvmReadTimeout);
    clientTelnetPkvm.WriteLine(PkvmPassword);

    clientTelnetPkvm.TerminatedRead("==>", PkvmReadTimeout);
    clientTelnetPkvm.WriteLine("2");
    clientTelnetPkvm.TerminatedRead("==>", PkvmReadTimeout);
    clientTelnetPkvm.WriteLine("1");
    clientTelnetPkvm.TerminatedRead("==>", PkvmReadTimeout);
    clientTelnetPkvm.WriteLine("2");
    string status = clientTelnetPkvm.TerminatedRead("==>", PkvmReadTimeout);
//status is always empty
    throw new NotImplementedException();
}

Hi Spechkin; your code looks ok to me but given you're having issues if you're using 0.8.2 have you tried using the 0.9.0-beta0001? A9G-Data-Droid did a lot of work extending the implementation to be more specification compliant but I've kept most of it on a beta to avoid adverse effects on the legacy base.

Alternatively you could try downloading and debugging the code to see where it's not handling your situation as you'd hoped...