이것이 간단할까요? 어떤 사람이 좋은 예가 있습니까? 내 모든 Google 검색은 dotNet에서 텔넷 클라이언트를 만드는 방법에 대한 항목을 반환하지만 나에게는이 과용이 있습니다. C#에서이 작업을 수행하려고합니다.C#에서 텔넷 연결을 열고 몇 가지 명령을 실행하는 방법
감사합니다.
이것이 간단할까요? 어떤 사람이 좋은 예가 있습니까? 내 모든 Google 검색은 dotNet에서 텔넷 클라이언트를 만드는 방법에 대한 항목을 반환하지만 나에게는이 과용이 있습니다. C#에서이 작업을 수행하려고합니다.C#에서 텔넷 연결을 열고 몇 가지 명령을 실행하는 방법
감사합니다.
C# 2.0 텔넷 -로 고통스럽지 그것은 소켓을 통해 연결 및 단지 송신 및 수신 (텔넷과 같은 인터페이스 특화된 하드웨어 장치에 연결하는 등의) 단일 타스크
http://geekswithblogs.net/bigpapa/archive/2007/10/08/C-2.0-and-Telnet---Not-As-Painful-As-It.aspx
를 소리 텍스트 명령으로 충분할 수 있습니다.
실제 텔넷 서버에 연결하려면 텔넷 이스케이프 시퀀스 처리, 터미널 에뮬레이션 처리, 대화식 명령 처리 등이 필요할 수 있습니다. Minimalistic Telnet library from CodeProject (무료) 또는 상용 텔넷/터미널 에뮬레이터 라이브러리 (예 : 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();