Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Nov : Indy V8...Trouble with TIdTCPClient's OnWork event...

www.cryer.info
Managed Newsgroup Archive

Indy V8...Trouble with TIdTCPClient's OnWork event...

Subject:Indy V8...Trouble with TIdTCPClient's OnWork event...
Posted by:"Jamie Dale" (j.da..@turboz.net)
Date:Thu, 2 Nov 2006 00:48:56

Hi

I'm using Indy V8 (Ok, i know it's old but I have my reasons ;) ).

I'm trying to use the TIdTCPClients OnWork event handler however it refuses
to activate.

I've looked into the source code and found what I THOUGHT was the problem:
(IdTCPConnection.pas)

procedure TIdTCPConnection.WriteBuffer(const ABuffer; AByteCount: Integer;
  const AWriteNow: boolean = false);
var
  nPos, nByteCount: Integer;

  procedure DefaultSend;
  begin
    nByteCount := Binding.Send(PChar(@ABuffer)[nPos - 1], AByteCount - nPos
+ 1,
      0);
    TIdAntiFreezeBase.DoProcess(False);
  end;

begin
  if (AByteCount > 0) and (@ABuffer <> nil) then
  begin
    CheckForDisconnect(True, True);

    if (FWriteBuffer = nil) or AWriteNow then
    begin
      nPos := 1;
      repeat
        if InterceptEnabled then
        begin
          if Intercept.SendHandling then
          begin
            nByteCount := Intercept.Send(PChar(@ABuffer)[nPos - 1],
AByteCount -
              nPos + 1);
          end
          else
          begin
            DefaultSend;
          end;
        end
        else
        begin
          DefaultSend;
        end;
        FClosedGracefully := nByteCount = 0;
        CheckForDisconnect;
        if GStack.CheckForSocketError(nByteCount, [ID_WSAESHUTDOWN]) then
        begin
          DisconnectSocket;
          GStack.RaiseSocketError(ID_WSAESHUTDOWN);
        end;
//***********LOOK HERE*******
       DoWork(wmWrite, nByteCount); // <== I THINK THIS IS THE PROBLEM!!!
        if InterceptEnabled then
        begin
          Intercept.DataSent(PChar(@ABuffer)[nPos - 1], AByteCount - nPos +
1);
        end;
        nPos := nPos + nByteCount;

      until nPos > AByteCount;
    end
    else
    begin
      FWriteBuffer.WriteBuffer(ABuffer, AByteCount);
      if (FWriteBuffer.Size >= FWriteBufferThreshhold) and
        (FWriteBufferThreshhold > 0) then
      begin
        FlushWriteBuffer(FWriteBufferThreshhold);
      end;
    end;
  end;
end;

If you notice, DoWork() doesn't actually have a valid nByteCount integer
unless there is an intercept so I assume, that DoWork is being passed a 0
instead?

With that in mind, I copied DoWork into DefaultSend on the 2nd line and
commented out DoWork in the main code. I then saved the file, removed Indy
from my IDE (deleting .bpl files while at it) recompiled and re-installed.

Still the progress bar in my Client does not get updated. Can someone please
advise?

I know this is an old version od Indy but to be honest, it's always done the
job for me. I'm not keen on the later versions..

Please help!

Jamie

Replies:

www.cryer.info
Managed Newsgroup Archive