Software Design: Tier 2 Application with ClientDataSet and Sockets

南楼画角 提交于 2019-12-11 09:52:46

问题


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

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

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).

I want to use TDBGrid on the client using data received via sockets from the server. At the moment it goes like this:

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

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

I am using SendDataToSocket(Socket: TCustomWinSocket; Data: Pointer; DataSize: Integer; Buffer: TMemoryStream): Integer;

So what I want to do is send the stream the clientdataset on the server side creates to the client who uses loadfromstream to read the stream. Is the SendDataToSocket viable here?

I hope you get what I mean.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/1244465/software-design-tier-2-application-with-clientdataset-and-sockets

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!