Delphi Datasnap Stream delivers big data

Source: Internet
Author: User

Delphi Datasnap Stream delivers big data

It is convenient for Datasnap to pass and return the parameters of the Tstream type directly. But a lot of people find that it's not normal to work if it's a little bit bigger.

Datasnap the default cache size is 32k so if the size of the stream exceeds this size it will be automatically divided into multiple packages, which is the basis for the delivery of large amounts of data, if a one-time transmission may be limited by memory.

When you pass a large amount of data, the size obtained is-1, so it is problematic to read the stream's data in a general way.

Because the data of the stream is sent by the original packet, the delivery speed is not much different from other methods without encrypting the packet.

FS is a file stream

function Tmydsserver.putfile (stream:tstream): Boolean;

Const

BufSize = $F 000;

Var

Buffer:tbytes;

Readcount:integer;

Begin

If stream.size = 1 then//size unknown then read until no data

Begin

SetLength (Buffer, BufSize);

Repeat

Readcount: = Stream.read (buffer[0], BufSize);

If Readcount > 0 Then

Fs. WriteBuffer (Buffer[0], readcount);

If Readcount < BufSize Then

Break

Until Readcount < BufSize;

End

else//size is known to copy data directly

Fs. CopyFrom (Stream, 0);

Result: = True;

End


Delphi Datasnap Stream delivers big data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.