Re: Winsock code

Giganews Newsgroups
Subject: Re: Winsock code
Posted by:  Remy Lebeau \(Indy Team\) (no.spam@no.spam.com)
Date: Wed, 13 Feb 2008

"sunrizer" <sunriz…@ukr.net> wrote in message
news:227D0AF17548E340sunriz…@ukr.net...

> If connection to SMTP-server failed and exception catched
> with message such as "10xxxx Read timeout" - how can I get
> this 10xxxx code from TIdSmtp-component ?

Type-cast the Exception object to a EIdSocketError (or catch EIdSocketError
directly), and then read its LastCode property, ie:

    try
        //...
    except
        on E: Exception do
        begin
            if E is EIdSocketError then
                // socket error, use EIdSocketError(E).LastError as
needed...
            else
                // not a socket error, do something else...
        end;
    end;

or:

    try
        //...
    except
        on E: EIdSocketError do
        begin
            // socket error, use E.LastError as needed...
        end;
        on E: Exception do
        begin
            // not a socket error, do something else...
        end;
    end;

Gambit

Replies

None

In response to

Winsock code posted by sunrizer on Wed, 13 Feb 2008