软件设计:具有ClientDataSet和Socket的Tier 2应用程序 [英] Software Design: Tier 2 Application with ClientDataSet and Sockets

查看:74
本文介绍了软件设计:具有ClientDataSet和Socket的Tier 2应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是按照以下步骤创建第2层应用程序:

I have the task to create a tier 2 application as follows:

MSSQL数据库<->服务器<-> n客户端(n为多个)

MSSQL Database <-> Server <-> n-Client (n for many)

客户端将数据发送到服务器。服务器从数据库中选择内容,然后将其发送回客户端。目前,我正在使用Records和SendDataToSocket(URL在下面)进行此操作。

The client sends data to the server. The server selects stuff from the database and then sends it back to the client. Currently I am doing that with Records and SendDataToSocket(url is below).

我想使用通过套接字从服务器接收的数据在客户端上使用TDBGrid。 目前,它是这样的:

服务器:
DB-> ADOQuery-> DataSetProvider-> ClientDataSet -> SaveToStream(MemoryStream)

Server: DB -> ADOQuery -> DataSetProvider -> ClientDataSet -> SaveToStream(MemoryStream)

客户端:
ClientDataSet-> LoadFromStream(MemoryStream)->数据源-> DBGrid

Client: ClientDataSet -> LoadFromStream(MemoryStream) -> DataSource -> DBGrid

我正在使用 SendDataToSocket(Socket:TCustomWinSocket; Data:Pointer; DataSize:Integer; Buffer:TMemoryStream):Integer;

所以我要做什么将服务器端上的clientdataset创建的流发送给使用loadfromstream读取流的客户端。 SendDataToSocket在这里可行吗?

我希望您明白我的意思。

推荐答案

是的,只要客户端准备好接收数据。这将很好地工作,但是根据您可能希望在发送之前压缩内存流的数据量和类型。我在以前的项目中也使用过类似的方法,但是我使用了突触进行数据传输...但是基本概念是相同的。

Yes, as long as the client was ready to receive the data. This would work well, however depending on the amount and type of data you might want to compress the memory stream prior to sending. I have performed a similar approach in previous projects, but I used synapse for the data transfer...but the basic concept was the same.

zlib单元(由CodeGear包含)包含一个围绕流的简单包装器,提供压缩和解压缩功能。由于您控制导线的两侧,因此压缩很可能会通过减少导线时间来提高性能。

The zlib unit (included by CodeGear) contains a simple wrapper around a stream which provides compression and decompression. Since your controlling both sides of the wire, compression will most likely increase performance by reducing wire time.

这篇关于软件设计:具有ClientDataSet和Socket的Tier 2应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆