Solved

Optimal stream packet size

Posted on 2004-04-05
1
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…

710 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