PowerTCP Telnet for .NET

from $349.00
Available Platforms

See all PowerTCP Telnet for .NET Code Examples

 Receive and Display Data Example

The following example demonstrates receiving data and displaying it.

 

//Telnet.Read(buffer) performs a single socket read, blocking until at least one byte is read, up to as much data as is available on the socket or buffer.Length, whichever is lowest.
//This code will block until the connection is closed or Telnet.SocketOption.ReceiveTimeout has expired.

Telnet telnet1 = new Telnet();
telnet1.Connect("myServer");
telnet1.Login(new Credentials("myUsername", "myPassword", "$");
try
{
    byte[] buffer = new byte[1024];
    Data data = telnet1.Read(buffer);
    while (data != null)
    {
        Console.Write(data.ToString());
        data = telnet1.Read(buffer);
    }
}
catch(Exception ex)
{
    //handle exception as desired
}
finally
{
    telnet1.Close();
}

 

To download a trial please visit the PowerTCP Telnet for .NET product page.