Sending Telnet Command via TCP/IP Socket

Discussion in 'Microsoft C# .NET' started by Ben, Apr 17, 2012.

  1. Ben

    Ben Guest

    Does anyone kow how I can send the telnet command via socket to
    disable Local Echo? I have read RFC857 but I still don't understand
    how I structure and send the telnet commands to the server.

    Any help would be greatly appreciated.
     
    Ben, Apr 17, 2012
    #1
    1. Advertisements

  2. Ben

    Ben Guest

    Code Sample

    // Connect to a remote device.
    try
    {
    // Establish the remote endpoint for the socket.
    // The name of the
    // remote device is "host.contoso.com".
    // IPHostEntry ipHostInfo =
    Dns.Resolve("host.contoso.com");
    // IPAddress ipAddress = ipHostInfo.AddressList[0];

    IPEndPoint remoteEP = new IPEndPoint(IPAddress, port);

    // Create a TCP/IP socket.
    client = new Socket(AddressFamily.InterNetwork,
    SocketType.Stream, ProtocolType.Tcp);

    // Connect to the remote endpoint.
    client.BeginConnect(remoteEP,
    new AsyncCallback(ConnectCallback), client);
    connectDone.WaitOne();


    // Receive the response from the remote device.
    Receive(client);
    receiveDone.WaitOne();

    // Write the response to the console.
    Console.WriteLine("Response received : {0}",
    response);



    //// Send test data to the remote device.
    Send(client, "admin");
    Send(client, System.Environment.NewLine);
    sendDone.WaitOne();

    // Receive the response from the remote device.
    Receive(client);
    receiveDone.WaitOne();

    // Write the response to the console.
    Console.WriteLine("Response received : {0}",
    response);

    // Send test data to the remote device.
    Send(client, "microchip");
    Send(client, System.Environment.NewLine);
    sendDone.WaitOne();

    // Receive the response from the remote device.
    Receive(client);
    receiveDone.WaitOne();


    // Write the response to the console.
    Console.WriteLine("Response received : {0}", response);
     
    Ben, Apr 17, 2012
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dario
    Replies:
    4
    Views:
    199
    Daniel O'Connell
    Oct 13, 2003
  2. Joe
    Replies:
    1
    Views:
    870
    BMermuys
    Dec 21, 2003
  3. Jonas Hei
    Replies:
    2
    Views:
    1,561
    Jonas Hei
    Jun 22, 2005
  4. Markgoldin

    Sending XML data via socket

    Markgoldin, Jul 30, 2008, in forum: Microsoft C# .NET
    Replies:
    10
    Views:
    340
    Markgoldin
    Aug 4, 2008
  5. puzzlecracker

    Socket vs TCP socket

    puzzlecracker, Oct 15, 2008, in forum: Microsoft C# .NET
    Replies:
    1
    Views:
    145
    Kerem Gümrükcü
    Oct 15, 2008
Loading...

Share This Page