Solved

Optimal stream packet size

Posted on 2004-04-05
1
180 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 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