c#通过telnet向我的fritzbox 7141发送评论以控制LED [英] c# send comments via telnet to my fritzbox 7141 to controll the leds
问题描述
大家好,
我需要一些帮助,希望您能帮助我.
因为我开始用C#编写一个小工具,将一些推荐的telnet发送到我的fritz.box 7141来控制led灯.但是在我的dosn´t程序中,我不知道为什么.
我不会发送推荐的"echo 1,3>/dev/new_led"和"echo 1,4>/dev/new_led"
我的fritzbox ip是192.168.178.1端口23
连接有效,但没有其他功能.你能找到我的错误吗?我迷失了问题...我该如何通过telnet发送订单?
谢谢你的帮助!!!!并为我的英语不好而发声
ii想通过c# http://www.youtube.com/watch?v=3cDZNmpAghA [ ^ ]
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[^]
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
推荐答案
我在程序中没有语法错误.但是我无法将注释"echo 1,3>/dev/new_led"发送给fritzbot,因此没有任何反应.
现在我把我发错了
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
这篇关于c#通过telnet向我的fritzbox 7141发送评论以控制LED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!