Speed issue using TIdTCPClient and TIdTCPServer

Hi

I'm using TIdTCPServer in conjunction with TIdIOHandlerThrottle and 
TIdIOHandlerSocket.

I am adjusting the Throttler using a progress bar - maximum is 102400 - 
which when div 1024 gives me a max of 100KBytes per second (theoretically 
anyway)

The code I am using to adjust this is as such:

procedure TForm2.AdjustSpeed(SpeedBytes: Integer);
var
RealBytes: Real;
begin
IdIOHandlerThrottle1.BytesPerSec := SpeedBytes;
RealBytes := SpeedBytes / 1024;
Label1.Caption := Format('%nKbps (%dbps)', [RealBytes, SpeedBytes]);
end;

procedure TForm2.TrackBar1Change(Sender: TObject);
var
SpeedBytes: Integer;
begin
SpeedBytes := TrackBar1.Position;
AdjustSpeed(SpeedBytes);
end;

I am also using this code to monitor the transfer:

procedure TForm2.Timer1Timer(Sender: TObject);
var
BytesSince: Integer;
begin
BytesSince := CurrentSize - LastSize;
Label3.Caption := IntToStr(BytesSince div 1024);
LastSize := CurrentSize;
Label5.Caption := IntToStr(IdIOHandlerThrottle1.BytesPerSec) + ' / '
+ IntToStr(IdIOHandlerThrottle1.BytesPerSec div 1024);
Label7.Caption := IntToStr(IdIOHandlerThrottle1.BitsPerSec) + ' / '
+ IntToStr((IdIOHandlerThrottle1.BitsPerSec div 8) div 1024);
Label9.Caption := IntToStr(Seconds);
Inc(Seconds);
end;

Things are dandy when the trackbar represent 32k and below. Above 32k it 
struggles upto 36k. That is the absolute maximum speed it will perform - 
Until the trackbar is at around 60K at which point the speed then increases 
to 64K max. It won't do anything in between though - IE 45k. It also won't 
go above 64K.

This is for uploading to a server on the same machine or on a different 
machine on the lan. I've not yet tested download speed..

Why is this? - Is it a windows issue or something I've done wrong? - I'll 
post the full source in a seperate reply.

TIA
0
Jamie
8/19/2008 9:03:45 PM
embarcadero.delphi.winsock 1874 articles. 2 followers. Follow

4 Replies
1461 Views

Similar Articles

[PageSpeed] 35

Main unit source:
unit Client_Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, ComCtrls, IdIOHandler, IdIOHandlerThrottle,
IdIOHandlerSocket, IdAntiFreezeBase, IdAntiFreeze, Writer;
type
TUser = Packed Record
User, Email: String;
end;
type
TForm2 = class(TForm)
IdTCPClient1: TIdTCPClient;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
ProgressBar1: TProgressBar;
Button3: TButton;
GroupBox1: TGroupBox;
Edit2: TEdit;
GroupBox2: TGroupBox;
Edit1: TEdit;
GroupBox3: TGroupBox;
IdIOHandlerThrottle1: TIdIOHandlerThrottle;
TrackBar1: TTrackBar;
Label1: TLabel;
IdIOHandlerSocket1: TIdIOHandlerSocket;
IdAntiFreeze1: TIdAntiFreeze;
GroupBox4: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Timer1: TTimer;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure IdTCPClient1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure IdTCPClient1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure Button3Click(Sender: TObject);
procedure IdTCPClient1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
procedure AdjustSpeed(SpeedBytes: Integer);
procedure TrackBar1Change(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
OldCaption: String;
MaxFileSize, LastSize, CurrentSize, Seconds: Integer;
end;

var
Form2: TForm2;

implementation
{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
IdTCPClient1.Host := Edit2.Text;
IdTCPClient1.Connect();
IdTCPClient1.WriteLn('identify¦' + Edit1.Text);
end;

procedure TForm2.Button2Click(Sender: TObject);
var
FileStream: TFileStream;
Writer: TWriter;
begin
If OpenDialog1.Execute then
begin
Writer := TWriter.Create(True);
Writer.FileName := OpenDialog1.FileName;
Writer.FreeOnTerminate := True;
Writer.Suspended := False;
end;
end;

procedure TForm2.IdTCPClient1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
ProgressBar1.Position := AWorkCount;
CurrentSize := AWorkCount;
end;

procedure TForm2.IdTCPClient1WorkBegin(Sender: TObject;
AWorkMode: TWorkMode; const AWorkCountMax: Integer);
begin
Case AWorkMode of
wmRead:
begin
OldCaption := Caption;
Caption := 'RX''ing';
end;
wmWrite:
begin
OldCaption := Caption;
Caption := 'TX''ing';
end;
end;
ProgressBar1.Position := 0;
ProgressBar1.Max := AWorkCountMax;
MaxFileSize := AWorkCountMax;
LastSize := 0;
Timer1.Enabled := True;
Seconds := 0;
end;

procedure TForm2.Button3Click(Sender: TObject);
var
FileName: String;
FileSize: Integer;
FileStream: TFileStream;
begin
FileName := ExtractFilePath(ParamStr(0)) + IdTCPClient1.ReadLn;
FileStream := TFileStream.Create(FileName, fmCreate);
IdTCPClient1.ReadStream(FileStream);
FreeAndNil(FileStream);
end;

procedure TForm2.IdTCPClient1WorkEnd(Sender: TObject;
AWorkMode: TWorkMode);
begin
Caption := OldCaption;
Timer1.Enabled := False;
end;

procedure TForm2.AdjustSpeed(SpeedBytes: Integer);
var
RealBytes: Real;
begin
IdIOHandlerThrottle1.BytesPerSec := SpeedBytes;
RealBytes := SpeedBytes / 1024;
Label1.Caption := Format('%nKbps (%dbps)', [RealBytes, SpeedBytes]);
end;

procedure TForm2.TrackBar1Change(Sender: TObject);
var
SpeedBytes: Integer;
begin
SpeedBytes := TrackBar1.Position;
AdjustSpeed(SpeedBytes);
end;

procedure TForm2.Timer1Timer(Sender: TObject);
var
BytesSince: Integer;
begin
BytesSince := CurrentSize - LastSize;
Label3.Caption := IntToStr(BytesSince div 1024);
LastSize := CurrentSize;
Label5.Caption := IntToStr(IdIOHandlerThrottle1.BytesPerSec) + ' / '
+ IntToStr(IdIOHandlerThrottle1.BytesPerSec div 1024);
Label7.Caption := IntToStr(IdIOHandlerThrottle1.BitsPerSec) + ' / '
+ IntToStr((IdIOHandlerThrottle1.BitsPerSec div 8) div 1024);
Label9.Caption := IntToStr(Seconds);
Inc(Seconds);
end;
end.

********************Writing Thread source
unit Writer;
interface
uses
Classes, SysUtils;
type
TWriter = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
FileName: String;
end;
implementation
{ Important: Methods and properties of objects in VCL or CLX can only be 
used
in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,

procedure TWriter.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ TWriter }
uses Client_Main;

var
FileStream: TFileStream;

procedure TWriter.Execute;
begin
{ Place thread code here }
FileStream := TFileStream.Create(FileName, fmOpenRead);
Form2.IdTCPClient1.WriteLn('file¦' + ExtractFileName(FileName));
Form2.IdTCPClient1.WriteStream(FileStream, True, True);
FreeAndNil(FileStream);
end;
end.
0
Jamie
8/19/2008 9:17:09 PM
Turns out its something to do with VMWare as after running further tests on 
physical machines it doesn't replicate the issue.

Thanks anyway ;)


"Jamie Dale" <jamie.dale@yahoo.com> wrote in message 
news:4698@forums.codegear.com...
> Hi
>
> I'm using TIdTCPServer in conjunction with TIdIOHandlerThrottle and 
> TIdIOHandlerSocket.
>
> I am adjusting the Throttler using a progress bar - maximum is 102400 - 
> which when div 1024 gives me a max of 100KBytes per second (theoretically 
> anyway)
>
> The code I am using to adjust this is as such:
>
> procedure TForm2.AdjustSpeed(SpeedBytes: Integer);
> var
> RealBytes: Real;
> begin
> IdIOHandlerThrottle1.BytesPerSec := SpeedBytes;
> RealBytes := SpeedBytes / 1024;
> Label1.Caption := Format('%nKbps (%dbps)', [RealBytes, SpeedBytes]);
> end;
>
> procedure TForm2.TrackBar1Change(Sender: TObject);
> var
> SpeedBytes: Integer;
> begin
> SpeedBytes := TrackBar1.Position;
> AdjustSpeed(SpeedBytes);
> end;
>
> I am also using this code to monitor the transfer:
>
> procedure TForm2.Timer1Timer(Sender: TObject);
> var
> BytesSince: Integer;
> begin
> BytesSince := CurrentSize - LastSize;
> Label3.Caption := IntToStr(BytesSince div 1024);
> LastSize := CurrentSize;
> Label5.Caption := IntToStr(IdIOHandlerThrottle1.BytesPerSec) + ' / '
> + IntToStr(IdIOHandlerThrottle1.BytesPerSec div 1024);
> Label7.Caption := IntToStr(IdIOHandlerThrottle1.BitsPerSec) + ' / '
> + IntToStr((IdIOHandlerThrottle1.BitsPerSec div 8) div 1024);
> Label9.Caption := IntToStr(Seconds);
> Inc(Seconds);
> end;
>
> Things are dandy when the trackbar represent 32k and below. Above 32k it 
> struggles upto 36k. That is the absolute maximum speed it will perform - 
> Until the trackbar is at around 60K at which point the speed then 
> increases to 64K max. It won't do anything in between though - IE 45k. It 
> also won't go above 64K.
>
> This is for uploading to a server on the same machine or on a different 
> machine on the lan. I've not yet tested download speed..
>
> Why is this? - Is it a windows issue or something I've done wrong? - I'll 
> post the full source in a seperate reply.
>
> TIA
0
Jamie
8/21/2008 12:03:06 AM
Jamie Dale wrote:
> Turns out its something to do with VMWare as after running further tests on 
> physical machines it doesn't replicate the issue.
> 

This is good to know, thanks for the update.

--
Jack
0
Jack
8/21/2008 2:33:46 PM
"Jack Mays" <jackmays@supplant.net> wrote in message 
news:5280@forums.codegear.com...
> Jamie Dale wrote:
>> Turns out its something to do with VMWare as after running further tests 
>> on
>> physical machines it doesn't replicate the issue.
>>
>
> This is good to know, thanks for the update.

No probs!

VMware by default uses only a 10Mb virtual connection. I didn't realise 
though that it would have odd effects on the speed of TCP filestream 
transfers though.

Must be issue with the VMware networking software. The absolute maximum 
speed I could transfer at was 64K. Lower down was 32k but on occassions it 
would jump to 36k. Nothing above that though until it was allowed 64k or 
more.
0
Jamie
8/22/2008 12:22:10 AM
Reply:

Similar Artilces:

To use or not to use Delphi
Sadly, it seems to me that there is a sort of race between the two threads, for and against using Delphi in new projects, with more or less the same users posting in both threads. Arguments are fiercely debated in both camps. Borland had their own vision. As a community, now that Delphi has changed ownership I believe we should try to be more consistent, more clear, and more articulate in what we expect from Embercadero in terms of Delphi. We can contribute to keeping Delphi alive and moving in the right direction. "Laurent Cocea" schrieb: > Sadly, it seems to me that there ...

TidTCPClient/TidTCPServer
I have a big problem when using TidTCPClient/TidTCPServer to send stream data from Client to Server and back. My Delphi codes: procedure TfrmTestIdTCPServer.cmdStartServerClick(Sender: TObject); begin IdTCPServer1.DefaultPort := 1000; IdTCPServer1.Active := True; end; procedure TfrmTestIdTCPServer.cmdConnectClick(Sender: TObject); begin IdTCPClient1.Host := '127.0.0.1'; IdTCPClient1.Port := 1000; IdTCPClient1.Connect; //Connecttion is fine cmdClientSendClick(Self); //Send Stream to Server end; procedure TfrmTestIdTCPServer.cmdClientSendClick(Sender: TO...

Speed Speed Speed
Name: Arthur A Lilford Email: arthuratposdriversdotcodotza Product: Firefox Summary: Speed Speed Speed Comments: Thanks Speed is great that is what gets me happy Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1b4) Gecko/20090423 Firefox/3.5b4 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

Issue with TWebBrowser(Delphi 2009) when using explorer 9
Hi, I am facing a strange issue when using TWebBrowser with Delphi 2009 and Explorer 9. What I am trying to do is loading a html page and then printing it. But if Explorer version is 9, then even the scroll bar of the window get printed and also if the document is more than one page, only what is visible at the window is getting printed !!! this issue is only reproducable if explorer 9 used along with delphi 2009. other versions of explorer work fine. Is this because delphi 2009 is not compatible with Explore r 9 ????? Code is as below. WebBrowser1.ControlInterface.ExecWB(OLECMDID_PRINT...

Issues in using reporting services we are using vs2005 and adding reports "*.rdlc", and are facing with follwoing issues
1:-There is one Main report having 2 subreports in it, each sub reoprt has it own header and footer but when its called from Master report, the header and footer of the sub report doesnt show on the Master report, how to make them visible. 2:-If we need to add some customize code for the report, we used the CustomCode tab that appear when Properties link of that report is clicked, how can we acess the items on the report under that code ???like if the report has the subreports, tables and want to acess their visibility is there any way.?? 3:-How can we check in the cutomcode o...

Sending Files using TIdTCPServer + TIdTCPClient + SSL + Proxy [Edit]
i need to send the files from different location (remote place) to Server Location by using TCP/IP Protocol with Secured (SSL) & Proxy Enabled Environment using Internet. i am newbie in this Concept. please guide to me how to develop this type of scenarios or any another alternative way to send files. i am using Delphi2010 thanx in advance vijay wrote: > i need to send the files from different location (remote place) to > Server Location by using TCP/IP Protocol with Secured (SSL) & Proxy > Enabled Environment using Internet. > > i am newbie in this Con...

Delphi 2009 How do I fix Unicode issue when using PCSC interface api
Dear All, I have been trying to find out how to convert the pcsc smart card interface so it works with unicode. The changes dont seem very many, but whatever I do, I cannot seem to get it to work! The original code and test program is available here..... http://nobbi.com/download/pcsccomp.zip grateful for any ideas! Many Thanks Mark <Mark Williams> wrote in message news:283097@forums.embarcadero.com... > I have been trying to find out how to convert the pcsc > smart card interface so it works with unicode. The > changes dont seem very many, but whateve...

Using Delphi 7 and Delphi 2010
I had a project in Delphi 7. I worked on it in Delphi 2010. When I try to open the .dpr again in Delphi 7, the IDE toolbar widens across both monitors, and Delphi 7 locks up. It appears that Delphi 2010 modifies the .dpr in a way that makes Delphi 7 unable to open it again. All my forms & units appear to open fine in D7 after D2010, except for the warnings on the ExplicitHeight and ExplicitWidth properties being missing... I can easily recreate the .dpr, but is this expected behavior? Thanks. Tom Field wrote: > I had a project in Delphi 7. > > I worked o...

speed up SA11--how can i insert 10000 record in 1 second using c# or delphi with SA11
hi,all, We have a potenial customer who use mssql now. The speed of db is the most critical part for them. Use iSQL, I write a storeprocedure,which can insert 10000 record within 0.6s on my Dell D610. But using delphi7 and our ODBC driver, insert 10000 record would cost about 1.4~1.6 second. I already apply the in-memory license and use -im nw flag to speed up. The SA version is 11.0.1.2044. As customer said, they can use MSSQL and C# program to do this within 1 second on their server. I don't know the hardware of the server. And the customer said we can a test progr...

delphi Win32 using delphi .NET dll
Hi, I'm trying to use a delphi.NET dll in delphi.WIN32. I am currently using CodeGear Delphi 2007 with version2(base version) of .NET I can get the dll to import into the WIN32 application the only problem is when i include things such as: "using Classes,DateUtils, SysUtils" in the .NET dll the win32 application will instantly hang when any of the dll functions are called. Any help would be great thanks. Also I have tried this example and it also crashes for me? http://cc.embarcadero.com/Item/22688 -Braden I also found this.. "The problem is that, wehn you instal...

How design a COM using Delphi and Using in PB7?
I need some component, So, we want using DELPHI5 to develop a COM or Activex. What type of knowege or Skill I must know it. Can anyone tell us? from DRAOGN Can you explain what type of component you want to create? You may not need to a) build your own, or b) use Delphi. If the component should be used from within a PB application, you ought to use PB to develop it unless it is something that PB does not let you do. regards, Bill DRAGON wrote: > I need some component, So, we want using DELPHI5 to develop a COM or > Activex. > What type of knowege or Skill I ...

Issues with using a record type and using getmem
I have a record type defined. There are several fields, and I want to assign to them from a custom class: (D2010, win7) <code> type tmyrec record field1: pchar; ... end; type tmyclass = class ffield1: string; public property field1: string read ffield1 write ffield1; procedure assignto(var aMyRec: tmyrec); procedure freeMem(var aMyRec: tmyrec); end; ... procedure tmyclass.assignto(var aMyRec: tmyrec); begin if not assigned(aMyRec.field1) then getmem(aMyRec.field1,4); aMyRec.field1 := pchar(self.field1); end; ...

At use ipsec useful speed in the channel decreases?
At use ipsec useful speed in the channel decreases? ? Example: remoteuser-----internet---server_with_FTP remoteuser download (over internet) from the FTP with the sped: 15k/sec If use this: remoteuser(BM39vpnClient)--------INTERNET---BM39SP1--server_with_ftp How will be decreases channel speed ? What will be: 15 K/sec, 10 K/sec, 5 K/s ... ?? Any info, please. Serg -- serg, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been resolved? If not, y...

About Firefox 2.5 speed issue and GUI issue
Name: Kevin Wan Email: kevinetatyahoodotcom Product: Firefox Release Candidate Summary: About Firefox 2.5 speed issue and GUI issue Comments: Thanks to Mozilla's great work. Firefox product line is excellent in the history of software development. I'm a tester of Firefox 3.5, and I will some feedback to next version of Firefox. Overall, the performance of FF3.5 is very nice. But the big problem that is the Starting time to the first time launch the program. I'm my test, FF3.0 and FF3.5 are the slowest in starting compare with all of major Browser in t...

Web resources about - Speed issue using TIdTCPClient and TIdTCPServer - embarcadero.delphi.winsock

In-App Purchase: SKRequest.start bug?
Since I’m using a third party component for In-App Purchasing, I’m not sure where this bug is, but it seems that SKRequest.start crashes when ...

The Hacker’s Corner
Since I’m using a third party component for In-App Purchasing, I’m not sure where this bug is, but it seems that SKRequest.start crashes when ...

Resources last updated: 2/6/2016 10:13:36 PM