Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top