Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jun : IdNNTP OnWork doesn't Fire
| Subject: | IdNNTP OnWork doesn't Fire |
| Posted by: | "Jack MacRank" (ja..@macrank.com) |
| Date: | Fri, 23 Jun 2006 20:36:18 |
Hi Remy,
Sorry to bother you again but I really exausted every avenue to solve this
issue.
I'm testing out the IdNNTP (10.1.5 6/22/06 source) along with the
TIdInterceptThrottler component to throttle the posting speed. Together
everything works very nice.
I'm having a problem though that occurs when just using IdNNTP by itself and
also when using IdNNTP with the TIdInterceptThrottler when setting the
BitsPerSec property to 0. The problem is that the OnWork event doesn't fire
and when researching this with a sniffer I found that only 32KB of data was
being sent and then abruptly quits resulting in the application freezing. I
read in the Indy10 help that the default send/recv buffer is 32KB which
might have something to do with the problem. The file I'm sending is over
2.5MB also.
I have events wired to OnWorkBegin, OnWork and OnWorkEnd. When the problem
occurs only the OnWorkBegin and OnWorkEnd fire. Below is my entire code.
Thanks for your help again, I really appreciate it!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdIntercept, IdInterceptThrottler, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,
IdMessageClient, IdNNTP, StdCtrls;
type
TfrmMain = class(TForm)
nntp: TIdNNTP;
btnPost: TButton;
memLog: TMemo;
throttler: TIdInterceptThrottler;
procedure btnPostClick(Sender: TObject);
procedure nntpWorkBegin(ASender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: Int64);
procedure nntpWork(ASender: TObject; AWorkMode: TWorkMode;
AWorkCount: Int64);
procedure nntpWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
uses
IdGlobal, IdObjs, IdSys;
var
startTime: Cardinal;
workMax : Int64;
{$R *.dfm}
procedure TfrmMain.btnPostClick(Sender: TObject);
var
postStream, partStream: TIdStream;
procedure Msg(const ALine: string);
begin
WriteStringToStream(postStream, ALine + EOL);
end;
begin
postStream := TIdMemoryStream.Create;
try
Msg('From: Jack MacRank <jack@macrank.com>');
Msg('Newsgroups: alt.binaries.test');
Msg('Subject: CommandPost2 Test 50');
Msg('Organization: None');
Msg('X-Newsreader: CommandPost v2.00');
Msg('');
partStream := TIdReadFileExclusiveStream.Create('C:\odac7.exe.ntx');
try
postStream.CopyFrom(partStream, 0);
finally
Sys.FreeAndNil(partStream);
end;
postStream.Position := 0;
nntp.Connect;
try
nntp.Post(postStream);
finally
nntp.Disconnect;
end;
finally
Sys.FreeAndNil(postStream);
end;
end;
procedure TfrmMain.nntpWorkBegin(ASender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: Int64);
begin
startTime := GetTickCount;
workMax := AWorkCountMax;
memLog.Lines.Add('S Tick: ' + IntToStr(startTime) + ' / S Work: ' +
IntToStr(workMax));
end;
procedure TfrmMain.nntpWork(ASender: TObject; AWorkMode: TWorkMode;
AWorkCount: Int64);
begin
memLog.Lines.Add('Tick: ' + IntToStr(GetTickCount - startTime) + ' / Work:
' +
IntToStr(AWorkCount) + ' / ' + Format('%f KB/s', [(AWorkCount /
(GetTickDiff(startTime, GetTickCount) / 1000)) / 1024]));
end;
procedure TfrmMain.nntpWorkEnd(ASender: TObject; AWorkMode: TWorkMode);
begin
memLog.Lines.Add('End Work: ' + IntToStr(GetTickCount - startTime));
end;
end.