Board index » delphi » How to get last Indy Socket error code

How to get last Indy Socket error code

Hi,

Im trying to get the last error code, when
a ftp connection fails.

with IdFtp do
     try Host     := aHost;
         Username := aUsername;
         Password := aPassword;
         Connect;
         except
          AnyError := true;
           end;

if AnyError then
   Result := IdFTP.xxxGetLastErrorxxx ?

Is there a way to get the last socket error code?
I didnt found a property for that.
(And GetLastError does not work)

Thanks for any hint.

 

Re:How to get last Indy Socket error code


Is there a way to get the last socket error code?

Quote
> I didn?t found a property for that.
> (And GetLastError does not work)

GetLastError is probably called in Indy to generate the exception object
when a winsock error occurs.  I think you will have to resort to getting
the error code from this object when a winsock error happens.  
EldSocketError certainly has a lastError property but the top Indy
exception class does not.  For Indy non-socket exceptions, I guess you
could define your own error codes, if you really want to.

Do you have to have this number, or can you just log/whatever the
exception.message?

Rgds,
Martin

Re:How to get last Indy Socket error code


Quote
> Do you have to have this number, or can you just log/whatever the
> exception.message?

Thanks, I found another solution (I have to add "IdStack" unit to uses
clause)

if AnyError then begin
   Result := GStack.LastError; // for WinSock errors
   if Result = 0 then
      Result := IdFtp.LastCmdResult.NumericCode; // for server error codes
  ...

Re:How to get last Indy Socket error code


"Steve" <no.s...@inbox54.com> wrote in news:3eead2e9@newsgroups.borland.com:

Quote
>> Do you have to have this number, or can you just log/whatever the
>> exception.message?

> Thanks, I found another solution (I have to add "IdStack" unit to uses
> clause)

Its easier to look in exception, it has a property which contains the error
number.\

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
      "Programming is an art form that fights back"

   Qualified help FAST with Indy Experts Support
   from the experts themselves:

   http://www.atozedsoftware.com/indy/experts/support.html

ELKNews - Get your free copy at http://www.atozedsoftware.com

Other Threads