Solved

Optimal stream packet size

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

631 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