Delphi DataSnap连接超时设置无效解决方法

Delphi DataSnap连接超时设置无效解决方法

目 录

解决问题:delphi D10下(XE8\XE7),DataSnap连接超时设置在android中使用无效,导致不能连接服务器时长时间等待。补丁包带源码及说明。
Datasnap ConnectTimeout android

该问题修改三个文件:

  • Data.DbxSocketChannelNative.pas
    增加390行、399行两处代码;(修改后文件)
  • IPPeerClient.pas
    增加114-117代码行;及对应函数与过程内容;(修改后文件)
  • IPPeerAPI.pas
    增加514-519接口定义 无对应代码。(修改后文件)

    对应QC: http://qc.embarcadero.com/wc/qcmain.aspx?d=80954

代码已上传到csdn下载区:http://download.csdn.net/detail/tanqth/9798195
支持 RAD10.1.1(10.1 UP1),其他版本请参照修改。
-下载后,将文件放入到您工程目录内就行,或将他们复制到其他一个统一的目录,您所有的工程都从这个统一的目录加载这些文件。

1、Data.DbxSocketChannelNative.pas

  timeout := DbxProperties[TDBXPropertyNames.ConnectTimeout];
  if timeout = '' then
        ConnectTimeout := 0
    else
        ConnectTimeout := StrToInt(timeout);
        //设置网络连接超时  2017-3-29 谭钦
    FIdSocket.ConnectTimeout:= ConnectTimeout;

  commTimeout := DbxProperties[TDBXPropertyNames.CommunicationTimeout];
  if commTimeout = '' then
    CommunicationTimeout := 0
    else
        CommunicationTimeout := StrToInt(commTimeout);
  //设置网络读超时  2017-3-29 谭钦
    FIdSocket.ReadTimeout:=CommunicationTimeout;

2、IPPeerClient.pas

        //begin 增加设置网络连接(读取)超时 2017-3-29 谭钦
        function GetConnectTimeout: Integer;
        procedure SetConnectTimeout(timeout: Integer);
        function GetReadTimeout: Integer;
        procedure SetReadTimeout(timeout: Integer);
        //End

function TIdTCPClientPeerIP.GetConnectTimeout: Integer;
begin
    Result := FTCPClient.ConnectTimeout;
end;

procedure TIdTCPClientPeerIP.SetConnectTimeout(timeout: Integer);
begin
    FTCPClient.ConnectTimeout := timeout;
end;

function TIdTCPClientPeerIP.GetReadTimeout: Integer;
begin
    Result := FTCPClient.ReadTimeout;
end;

procedure TIdTCPClientPeerIP.SetReadTimeout(timeout: Integer);
begin
    FTCPClient.ReadTimeout:=timeout;
end;

3、IPPeerAPI.pas

        //begin 增加网络连接(读取)超时设置 2017-3-29 谭钦
        function GetConnectTimeout: Integer;
        procedure SetConnectTimeout(timeout: Integer);
        property ConnectTimeout: Integer read GetConnectTimeout write SetConnectTimeout;
        function GetReadTimeout: Integer;
        procedure SetReadTimeout(timeout: Integer);
        property ReadTimeout: Integer read GetReadTimeout write SetReadTimeout;
        //end
发布了20 篇原创文章 · 获赞 29 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/tanqth/article/details/68212562