Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Idtelnet sendCmd()

206 views
Skip to first unread message

Dean Humphreys

unread,
Oct 1, 2007, 10:53:34 AM10/1/07
to
Hi I am trying to send a telnet command using the sendCmd() routine. The
command is defiantly being sent because the command is received by the
host. The problem is that the component then freezes the app. There is
no return from the command being sent. I have tried to use TidAntifreeze
with no success. I have also tried to create a separate thread to send
the command, this works but then the thread runs out of memory and slow
the app down.

What is the correct way to use this routine? How do i stop it from
freezing the app.

Thank you

Dean

Remy Lebeau (TeamB)

unread,
Oct 1, 2007, 2:17:03 PM10/1/07
to

"Dean Humphreys" <dean.hu...@gmail.com> wrote in message
news:4701...@newsgroups.borland.com...

> Hi I am trying to send a telnet command using the sendCmd() routine.

You cannot use SendCmd() with TIdTelnet at all. TIdTelnet has an internal
reading thread that interfers with SendCmd()'s own reading, and vice versa.
The only reason SendCmd() exists in TIdTelnet is because it is inherited
from TIdTCPConnection. TIdTelnet is not designed to be used as a
command+response component. To send a command, you can use WriteLn()
instead of SendCmd(), but to receive the response you have to use the
OnDataAvailable event and buffer the inbound data separately.

> The command is defiantly being sent because the command is received
> by the host. The problem is that the component then freezes the app.

As it should be. TIdTelnet's internal reading thread ends up receiving some
or all of the data that SendCmd() is expecting, thus SendCmd() becomes
blocked waiting for data it will never receive.

> What is the correct way to use this routine?

Don't use SendCmd() with TIdTelnet at all. Use TIdTCPClient directly
instead.


Gambit


0 new messages