Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi every body,

i need some help and i hope you can help me.

because i started to programming a little tool in c# to send some telnet commends to my fritz.box 7141 to controll the led-lights. but in my programm in dosn´t works an i don´t know why.
i wont to send the commend "echo 1,3 > /dev/new_led" and "echo 1,4 > /dev/new_led"
my fritzbox ip is 192.168.178.1 port 23

the connection works but nothing else. can you find my mistake? i be lost with the problem... how can i send my orders via telnet ?


Thank you for help!!!! and sry for my bad english


i i want to do is via c# http://www.youtube.com/watch?v=3cDZNmpAghA[^]
C#
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

public class SimpleTcpClient
{
    public static void Main()
    {
        byte[] data = new byte[1024];
        string input, stringData;

        Console.WriteLine("IP-adresse eingeben.");
        IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("192.168.178.1"),23);

        Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

        try
        {
            server.Connect(ipep);
        }
        catch (SocketException )
        {
            Console.Clear();//error output//
            Console.WriteLine("\n            Verbindung zu Experience 0O9 fehlgeschlagen  ");  
            Console.WriteLine("            mögliche fehler:\n");
            Console.WriteLine("             -Fehlerhafte IP-adresse");
            Console.WriteLine("             -Experience 0O9 nicht gestartet"); 
            Console.WriteLine("             -W-lan Deaktivirt oder nicht verfügbar");
            Console.WriteLine("             -Gerät außer Reichweite\n");
            //end error output//
            Main();
        }

        int recv = server.Receive(data);
        stringData = Encoding.ASCII.GetString(data, 0, recv);
        Console.Clear();
        Console.WriteLine("Verbunden");

        while (true)
        {
            input = Console.ReadLine();
            if (input == "esc")
                break;
            if (input == "w")
            { input = "echo 1,3 > /dev/new_led"; }

            server.Send(Encoding.ASCII.GetBytes(input));
            data = new byte[1024];

            recv = server.Receive(data);
            stringData = Encoding.ASCII.GetString(data, 1, recv);
            Console.WriteLine(stringData);
        }
        Console.WriteLine("Disconnecting from server...");
        server.Shutdown(SocketShutdown.Both);
        server.Close();
         }
}

Thank you for help!!!! and sry for my bad english
Posted
Updated 28-Dec-11 3:17am
v2
Comments
Wendelius 28-Dec-11 9:17am    
Pre tags added
Rajesh Anuhya 28-Dec-11 9:24am    
what is the error you are getting?
Nirvana19933 28-Dec-11 9:37am    
i have no syntax errors in the program. but im not able to send the the comment "echo 1,3 > /dev/new_led" to the fritzbot, there is no reaction.
and now i thing i send it wrong

1 solution

i have no syntax errors in the program. but im not able to send the the comment "echo 1,3 > /dev/new_led" to the fritzbot, there is no reaction.
and now i thing i send it wrong
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900