el programa funciona aunque no hagas oc! xD
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using De.Mud.Telnet;
using System.IO;
namespace Net.Graphite.Telnet
{
/// <summary>
/// A simple console testbed for the Telnet application.
/// </summary>
public class TestClient
{
[STAThread]
static void Main(string[] args)
{
string Direccion;
string puerto;
Direccion = "aqui va la ip del servidor telnet";
puerto = "23";
TestRun tr = new TestRun(Direccion, Int32.Parse(puerto));
try
{
tr.InteractiveSession();// edit the method for specific cmds
}
catch (Exception e)
{
Console.WriteLine("An exception has occurred: " +
e.Message + "\n\n" + e.StackTrace + "\n");
}
}
}
public class TestRun
{
private TelnetWrapper t;
private bool done = false;
private StreamReader sr;
public string Datos;
public TestRun(string host, int port)
{
t = new TelnetWrapper();
t.Disconnected += new DisconnectedEventHandler(this.OnDisconnect);
t.DataAvailable += new DataAvailableEventHandler(this.OnDataAvailable);
t.TerminalType = "NETWORK-VIRTUAL-TERMINAL";
t.Hostname = host;
t.Port = port;
Console.WriteLine("Connecting ...");
t.Connect();
}
public void ScriptedSession()
{
Console.WriteLine("Not implemented.");
}
public void InteractiveSession()
{
//int i;
//char ch;
try
{
t.Receive();
string envio;
envio = "admin\r\n";
string envio2;
string llegada;
envio2 = "sys iface\r\n";
//while (!done)
t.Send(envio + envio2);
//Console.ReadLine();
//t.Send(envio2);
//t.Send(Console.ReadLine() + t.CRLF);
}
catch
{
t.Disconnect();
throw;
}
}
private void OnDisconnect(object sender, EventArgs e)
{
done = true;
Console.WriteLine("\nDisconnected.");
}
public void OnDataAvailable(object sender, DataAvailableEventArgs e)
{
//Console.Write(e.Data);
this.Datos += e.Data
}
}
}