【发布时间】:2015-06-25 06:26:24
【问题描述】:
我正在使用 Delphi XE8 开发移动应用程序和桌面应用程序。在移动应用程序中,我使用 TIDtcpClient 组件,在桌面应用程序应用程序中,我使用 TServerSocket。
服务器桌面应用程序包含包含大约 1500 条记录的 TList。为了在 Client Mobile 应用程序中获取这些值,我使用以下方法。
- 首先下载请求从客户端移动应用程序发送到服务器应用程序。
- 接下来它检索 10 条记录并发送回客户端移动应用程序。在此之后,它更新客户端列表中的值,然后再次将请求发送回服务器应用程序。
- 直到记录数达到,这个过程继续。
问题是,当我使用这种方法时,它需要将近 2 分钟的时间,并且我可以正确获取所有数据。所以我决定使用文件流方法。下面我已经提到了示例代码:
服务器端应用:
//first saved the List into FileStream & it is working as I have reloaded and checked
//So again I'm loading the saved file, The file Size is near to 400KB
FileStream := TFileStream.Create('D:\ListDet.dat', mtfmOpenRead);
Socket.SendStream(FileStream);
客户端移动应用:
var
FileS: TFileStread;
i: Size;
begin
//Inside the thread
TiDTcpClient.IOHandler.ReadStream(FileS, i);
end;
当我使用上述方法时,我得到了异常,我无法检索数据。
请提供任何解决方案,以更快地从服务器检索数据到客户端。
【问题讨论】:
-
TServerSocket 组件已经过时和弃用了很长时间。我建议在服务器端使用 Indy。
-
I'm getting the exception...实际的异常类和消息是什么? -
我在客户端应用程序(移动)中正常关闭异常。
标签: sockets delphi indy delphi-xe8 tfilestream