indy10中IDFTP的神奇问题
IDFTP.connect 函数中有这么一段
- Delphi(Pascal) code
if IsSiteZONESupported then begin if SendCmd('SITE ZONE') = 210 then begin {do not localize} if LastCmdResult.Text.Count > 0 then begin LBuf := LastCmdResult.Text[0]; // some servers (Serv-U, etc) use a 'UTC' offset string, ie // "UTC-300", specifying the number of minutes from UTC. Other // servers (Apache) use a GMT offset string instead, ie "-0300". if TextStartsWith(LBuf, 'UTC-') then begin {do not localize} FTZInfo.GMTOffset := MDTMOffset(Copy(LBuf, 4, MaxInt)); end else begin FTZInfo.GMTOffset := GmtOffsetStrToDateTime(LBuf); end; FTZInfo.FGMTOffsetAvailable := True; end; end; end;使用IDFTP.connect 连接 linux主机时。
遇到 LBuf 返回值是UTC-2147483647 ,
这时MDTMOffset(Copy(LBuf, 4, MaxInt)); 就会range check error;
MDTMOffset函数代码是
- Delphi(Pascal) code
function MDTMOffset(const AOffs : String) : TDateTime; {$IFDEF USE_INLINE} inline; {$ENDIF}var LOffs : Integer;begin LOffs := IndyStrToInt(AOffs); {We use ABS because EncodeTime will only accept positve values} Result := EncodeTime(Abs(LOffs) div 60, Abs(LOffs) mod 60, 0, 0); if LOffs > 0 then begin Result := 0 - Result; end;end;EncodeTime的参数类型是word,所以返回值超过65535就肯定出错。
为什么会这样,难道都不会遇到会有这种返回值?
还是我的INDY10的IDFTP哪里没配置好?
[解决办法]
INDY10,对这个,,我也碰到过问题的。。
像IDHTTP,,我根据网址获取字符类型的返回值会乱码。。
然后我看了一下它的代码,数据是从WEB服务器返回的是流对象,从流对象转换成字符串这一步出错了。
比如本来我可以:AReturnStr:=Trim(FHttpClient.Get('http://fw.qq.com/ipaddress'))
但在delphi2010的indy10下,我必须得:
FHttpClient.Get('http://fw.qq.com/ipaddress', LStream, []);
LStream.Position := 0;
ZeroMemory(@AnsiArray[0],256);
LStream.ReadBuffer(AnsiArray[0],LStream.Size);
AReturnStr:=AnsiArray;
[解决办法]
据说ICS控件会稳定一点。