Francois PIETTE wrote:

>>    GetWinsockOrProxyErrorStr(ErrCode); // <== New function, not
>> related to this fix
> 
> I would name this function GetErrorMsgFromErrorCode since it is a
> general translation from an error number to a message.

IMO, from the name it should be clear what range of error numbers
are expected to be translated. Maybe "GetWinsockOrProxyErrorMsgFromErrorCode".

> Probably the
> implementation should as well call the API to get Windows error
> message description from Windows error code. 

Won't the API return localized messages? Not nice to have different
languages in log files or error messages.

> generic. We still have the problem of colliding error code which
> exists since the beginning. 

Can't this be solved by introducing a range reserved for component users?
And by introducing a global unit containing all those constants used by
ICS which might lead to conflicts, that would help us a lot to keep overview?
I found for instance SmtpProtocolError = 20600 in SmtpProt.pas yesterday.

-- 
Arno Garrels


> This way it is perfectly
> generic. We still have the problem of colliding error code which
> exists since the beginning. 
> 
> --
> francois.pie...@overbyte.be
> The author of the freeware multi-tier middleware MidWare
> The author of the freeware Internet Component Suite (ICS)
> http://www.overbyte.be
> 
> 
> ----- Original Message -----
> From: "Arno Garrels" <arno.garr...@gmx.de>
> To: "ICS support mailing" <twsocket@elists.org>
> Sent: Saturday, February 12, 2011 10:41 AM
> Subject: Re: [twsocket] TFtpCli strange logic
> 
> 
>> Francois PIETTE wrote:
>>>> 1) Command Open succeeds.
>>>> 2) After the server received command User it closes the connection
>>>> (FIN/ACK).
>>>> 3) OnSessionClosed triggers with ErrCode 0.
>>>> 4) OnRequestDone triggers with ErrCode 0 and the status code from
>>>> previous request.
>>>> 
>>>> Would you agree that is a bug?
>>> 
>>> If the server closes the connection as a reaction to a command
>>> except quit, then OnrequestDone should report a failure code,
>>> probably WSAECONNRESET.
>> 
>> Do you see anything obviously wrong in this fix?
>> 
>> 
>> procedure TCustomFtpCli.ControlSocketSessionClosed(
>>    Sender  : TObject;
>>    ErrCode : Word);
>> var
>>    LClosedState : TFtpState;
>> begin
>>    LClosedState := FState;
>>    if FConnected then begin
>>        FConnected := FALSE;
>>        if FState <> ftpAbort then
>>            StateChange(ftpNotConnected);
>>        if Assigned(FOnSessionClosed) then
>>            FOnSessionClosed(Self, ErrCode);
>>    end;
>>    if FState <> ftpAbort then
>>        StateChange(ftpInternalReady);
>>    if FRequestType <> ftpRqAbort then begin
>>        if (ErrCode <> 0) or ((FRequestType <> ftpQuitAsync) and  
>>           //<== (LClosedState in [ftpWaitingBanner,
>> ftpWaitingResponse])) then 
>> begin //<==
>>            FLastResponse  := '500 Control connection closed - ' +
>>                               GetWinsockOrProxyErrorStr(ErrCode); //
>> <== New function, not related to this fix
>>            FStatusCode    := 500;
>>            FRequestResult :=  FStatusCode;    { 06 apr 2002 }
>>            SetErrorMessage;
>>        end;
>>        TriggerRequestDone(FRequestResult);
>>    end;
>> end;
>> 
>> 
>> --
>> Arno Garrels
>> --
>> To unsubscribe or change your settings for TWSocket mailing list
>> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
>> Visit our website at http://www.overbyte.be
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to