これは簡単ですか?いずれかの良い例がありますか?私のすべてのGoogle検索では、ドットネットのtelnetクライアントを作成する方法についての項目が返されますが、この過剰なものは私のためにあります。私はC#でこれをやろうとしています。C#でtelnet接続を開き、いくつかのコマンドを実行する方法
ありがとうございます!
これは簡単ですか?いずれかの良い例がありますか?私のすべてのGoogle検索では、ドットネットのtelnetクライアントを作成する方法についての項目が返されますが、この過剰なものは私のためにあります。私はC#でこれをやろうとしています。C#でtelnet接続を開き、いくつかのコマンドを実行する方法
ありがとうございます!
C#2.0およびTelnet - としては痛くないそれは、ソケットを介して接続し、単に送受信(例えばtelnetのようなインタフェースを備えた専用のハードウェア・デバイスに接続するような)単純なタスクについて
http://geekswithblogs.net/bigpapa/archive/2007/10/08/C-2.0-and-Telnet---Not-As-Painful-As-It.aspx
を音としてテキストコマンドで十分でしょう。
実際のTelnetサーバに接続する場合は、telnetエスケープシーケンス、端末エミュレーション、対話型コマンドなどを処理する必要があるかもしれません。Minimalistic Telnet library from CodeProject(無料)や市販のTelnet/Terminal Emulatorライブラリ(Rebex Telnetなど)を使用すると、時間を節約できます。 (this urlから取られた)次のコード
はそれを使用する方法を示しています。
// create the client
Telnet client = new Telnet("servername");
// start the Shell to send commands and read responses
Shell shell = client.StartShell();
// set the prompt of the remote server's shell first
shell.Prompt = "servername# ";
// read a welcome message
string welcome = shell.ReadAll();
// display welcome message
Console.WriteLine(welcome);
// send the 'df' command
shell.SendCommand("df");
// read all response, effectively waiting for the command to end
string response = shell.ReadAll();
// display the output
Console.WriteLine("Disk usage info:");
Console.WriteLine(response);
// close the shell
shell.Close();