Forum > Networking and Web Programming

New Indy10_4620 of April 11, 2011 works in Lazarus

<< < (3/3)

jl:

--- Quote from: marcov on April 11, 2011, 01:25:22 pm ---One could try to just remove the redundant versions of the various .inc files. Mostly notably idcompilerdefines.inc

With that change, I can compile it easily.
--- End quote ---


I tried this on the latest Indy10_4625 + fpc 2.4, copied *.pas, *.lrs and *.inc of the \System, \Core, and \Protocols subdirectories into a new indy folder.  For repeated .inc, i simply override them.

I end up with the following inc.

IdCompilerDefines.inc
IdCore90ASM90.inc
IddclCore90ASM90.inc
IddclProtocols90ASM90.inc
IdProtocols90ASM90.inc
IdSecurity90ASM90.inc
IdSystem90ASM90.inc
IdVers.inc

However, to make it easier to switch indy versions, I did not install the package.

I merely add ..\indy to compiler options - \indy resides in the same parent folder as my project folder.

So after this, I created a test HTTP Console client, tested on both Win32 and Ubuntu platform.  On Win32, the HTTP client worked but generated some heap trace:


--- Quote ---<HTTP GET RESULTS>

Heap dump by heaptrc unit
2798 memory blocks allocated : 632164/645624
2795 memory blocks freed     : 632096/645544
3 unfreed memory blocks : 68
True heap size : 262144 (144 used in System startup)
True free heap : 264720
Should be : 261728
Call trace for block $0184E5C8 size 28
  $004667AD  TIDTHREADSAFE__CREATE,  line 223 of D:/Data/test/SMSD
tcher/lanprowler/Indy10_4625 test/indy/IdThreadSafe.pas
  $00466735  IDTHREAD_init,  line 638 of D:/Data/test/test/Indy10_4625 test/indy/IdThread.pas
  $0040A1A4
  $0040E271
  $00730065
  $0052005C
  $0078006F
  $006F0069
Call trace for block $01846AA0 size 12
  $00466735
  $0040A1A4
  $0040E271
Call trace for block $0184E4E8 size 28
  $004443EC
  $0040A1A4
  $0040E271
  $0077006F
  $00720065
  $00680053
  $006C0065
  $005C006C
--- End quote ---

On Ubuntu, it doesn't work at all:


--- Quote ---Error: Connection Closed Gracefully.

Heap dump by heaptrc unit
568 memory blocks allocated : 46766/49648
565 memory blocks freed     : 46698/49568
3 unfreed memory blocks : 68
True heap size : 458752
True free heap : 458432
Should be : 458480
Call trace for block $B7765300 size 28
  $080F6D5D  TIDTHREADSAFE__CREATE,  line 223 of /home/jtest/Desktop/Data/Indy10_4625 test/indy/IdThreadSafe.pas
  $080F6B25  IDTHREAD_init,  line 638 of /home/jtest/Desktop/Data/Indy10_4625 test/indy/IdThread.pas
  $0805A6D4
  $081149DD
Call trace for block $B77446C0 size 12
  $080F6B25  IDTHREAD_init,  line 638 of /home/jtest/Desktop/Data/Indy10_4625 test/indy/IdThread.pas
  $0805A6D4
  $081149DD
Call trace for block $B7765220 size 28
  $080C376C  IDSTACK_init,  line 937 of /home/jtest/Desktop/Data/Indy10_4625 test/indy/IdStack.pas
  $0805A6D4
  $081149DD
--- End quote ---

My test console:


--- Quote ---program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, SysUtils, CustApp, IdHTTP
    { you can add units after this };

type

  { TMyApplication }

  TMyApplication = class(TCustomApplication)
  protected
    procedure DoRun; override;
  public
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;
    procedure WriteHelp; virtual;
  end;

{ TMyApplication }

procedure TMyApplication.DoRun;
var
  ErrorMsg,Text: String;
    indy: TIdHTTP;
begin
  // quick check parameters
  ErrorMsg:=CheckOptions('h','help');
  if ErrorMsg<>'' then begin
    ShowException(Exception.Create(ErrorMsg));
    Terminate;
    Exit;
  end;

  // parse parameters
  if HasOption('h','help') then begin
    WriteHelp;
    Terminate;
    Exit;
  end;
  try
     try
     indy:= nil;
     indy:=TIdHTTP.Create(nil);
     indy.Name:='httpclient';
     indy.HandleRedirects:=true;
     Text := indy.Get('http://www.google.com');
     writeln(Text);

    except
          on E: Exception do
              writeln('Error: '+ E.Message);
    end;
  finally
   FreeAndNil(indy);
  end;


  // stop program loop
  Terminate;
end;

constructor TMyApplication.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  StopOnException:=True;
end;

destructor TMyApplication.Destroy;
begin
  inherited Destroy;
end;

procedure TMyApplication.WriteHelp;
begin
  { add your help code here }
  writeln('Usage: ',ExeName,' -h');
end;

var
  Application: TMyApplication;

//{$R *.res}

begin
  Application:=TMyApplication.Create(nil);
  Application.Run;
  Application.Free;
end.

--- End quote ---

Any thoughts?  Thanks.

Navigation

[0] Message Index

[*] Previous page

Go to full version