Re: Speed Limits cause EInvalidCast('Invalid class typecase')

Giganews Newsgroups
Subject: Re: Speed Limits cause EInvalidCast('Invalid class typecase')
Posted by:  ron (rrroo…
Date: Sun, 09 Nov 2003

If anyone else has this problem .. note the following changes that I had to make
in IdFTP:

In InternalGet:

  BoundIP := (Self.IOHandler as TIdIOHandlerSocket).Binding.IP;
if Self.IOHandler is TIdIOHandlerThrottle then
  BoundIP := ((Self.IOHandler as TIdIOHandlerThrottle).ChainedHandler as
  BoundIP := (Self.IOHandler as TIdIOHandlerSocket).Binding.IP;

Make the same change in InternalPut.

Indy assumes that the chanined handler is a TIdIOHandlerSocket which isn't the
case when using a TIdIOHandlerThrottle and this causes the Exception.  Note that
I haven't tried this with any other IOHandler, but a quick perusal of code
suggests that it should be ok and I can't see how it can make the current faulty
handling any worse.



ron wrote:
> Hi,
> I am using Indy 9.0.14 in Builder 6.  I am building a FTP client and
> have attached a Throttle IO handler to the Ftp client object and then
> chained this to an IO Socket handler.  I have set up the BPS to limit
> the amount of traffic. When I run the application, I get the
> EInvalidCast('Invalid class typecase') exception.  The call stack looks
> as follows:
> 7C4EA4E1 C:\WINNT\system32\kernel32.dll
> 00474C25 Idftp::TIdFTP::InternalGet
> 0052BEDC System::ErrorAt(ErrorCode=????, ErrorAddr=????)
> 0047490D Idftp::TIdFTP::List        <- indy code
> 00405686 TFormFTP::FTP_Exists(....})    <- my code
> and appears to occur as a result of IOHandler initialisation.
> I have read some previous posts and it appears to me that I'm doing
> things right.  Any ideas?
> Thanks,
> Ron
> PS I have previously posted this message to the .tcp but got no
> response, maybe this group is more approipriate.


In response to

Speed Limits cause EInvalidCast('Invalid class typecase') posted by ron on Thu, 06 Nov 2003