Solved

Optimal stream packet size

Posted on 2004-04-05
1
177 Views
Last Modified: 2010-04-05
I am streaming data from a TMemoryStream to clients using the following code.

  m.Seek(0,soFromBeginning);
  repeat
      begin
      {Play}
      Count := m.read(b,1024);
      AThread.Connection.WriteBuffer(b,count,True);
      sleep(5);
      end;
    until count<>1024;

What are your suggestions on the size of the data to send? 1024 bytes seems rather small. Typically the entire memory stream will be at least 5 megs. Normally the data will only be transferred on a LAN
0
Comment
Question by:rbohac
1 Comment
 
LVL 11

Accepted Solution

by:
shaneholmes earned 50 total points
ID: 10761896
1024 is the block norm, but testing your app and adjusting according will be the best method of determining the optimization for your application & network, watching your CPU & memory resources to determine the optimal.

I would add the capability of editing the value from a options dialog or such, and making this value persistent to the registry.

This way, users can change the value to optimize it to their network


 Count := m.read(b, gBufSize);


Unit UntReg;

interface

uses Windows, Registry, Classes, SysUtils;

procedure ReadRegistry;
procedure WriteRegistry;

var
 gBuffSize: Integer;
 
implementation

procedure WriteRegistry;
var
 Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\Software\YourCompanyName\YourAppName\', True) then
    begin
      Reg.WriteInteger('Buffer Size', gBufSize);
      Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;
end;

procedure ReadRegistry;
var
 Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\Software\YourCompanyName\YourAppName\', True) then
    begin
     if Reg.ValueExists('Buffer Size') then
       gBufSize := Reg.ReadInteger('Buffer Size');
      Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;
end;

initialization
  begin
    ReadRegistry;
  end;

finalization
begin
  WriteRegistry;
end;

end.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now