Need a sample / demo using TIdTelnet to interact with the telnet server

I tried using Indy 10.5.5 (shipped with Delphi 2010) for:

  • telnet server connection
  • username / password authentication (gaining access to the shell)
  • execution of a command with returning the returned data back to the application

and was unsuccessful, in addition, I completely lost the Indy spaghetti logic inside the company and now I don’t know why this does not work or how I should send lines to the server and get the results. Need some sample code to learn.


The formal form of the question is: where can I get the 3rd party demo covering the TIdTelnet component? (the webpage of the demo indyproject.org does not have)

+3
source share
2 answers

The main problem with Telnet is that it does NOT use the command / response model, as most other Internet protocols do. Any party can send data at any time, and each data direction is independent of the other direction. This is reflected in the TIdTelnetfact that an internal read stream is performed to receive data. Because of this, you cannot just connect, send a command and wait for an answer in one block of code, as you can, with other Indy components. You have to write a command and then wait for an event OnDataAvailableto trigger, and then analyze the data to determine what it really is (and be prepared to handle situations where partial data can be received, since that is how TCP / IP works.)

, /, TIdTCPClient TIdTelnet ( Telnet , Telnet, , ). Indy 11 TIdTelnet - , .

+4

indy. .. som :-) telnet kommand.. sendch.

telnetdude.Host := 1.1.1.1;
try
telnetdude.connect;
except
on E: Exception do begin
E.CleanupInstance;
end; {except}
if telnetdude.Connected then begin
for i := 1 to length(StringToSend) do telnetdude.sendch(StringToSend[i]);
telnetdude.sendch(#13);
end;
end; {while}
end; {if}
if telnetdude.Connected then telnetdude.Disconnect;
end;
+3

All Articles