Solved

Optimal stream packet size

Posted on 2004-04-05
1
176 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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

10 Experts available now in Live!

Get 1:1 Help Now