[Lazarus] Is porting Delphi program using AsyncPro to fpc/laz possible?
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Thu Jan 21 15:50:23 CET 2016
On 2016-01-21 14:10, Bo Berglund wrote:
>
> What svn URL do you recommend?
> And which tag?
I use the URL: https://svn.atozed.com:444/svn/Indy10/trunk
ie: I use Trunk (v10.6.2) directly. The repository is not that fast
moving, and Remy seems to be on the ball quite quickly if there are any
noted issues.
Attached you will find a drop-in replacement "indylaz.lpk" package file.
This is the fixed package and should hopefully appear in the repository
soon.
I've also attached a unit (small test suite for IPv4 TCP Client &
Server) which shows the setup of a TCP Server and TCP Client instance
and how the client connects to the server.
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: indylaz.lpk.zip
Type: application/zip
Size: 2171 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160121/5de07db7/attachment-0003.zip>
-------------- next part --------------
{
Tests to check if IPv4 and IPv6 works.
This is done by connection a TCPClient to a TCPServer.
NOTE:
the IPv6 test fails when there is no IPv6 support in the OS.
}
unit IPv4_tst;
{$IFDEF FPC}
{$mode delphi}
{$ENDIF}
{.$Define UseIOHandler}
interface
uses
Classes,
SysUtils,
TestFramework,
IdTCPServer,
IdContext;
type
// forward declaration
TMyTCPServer = class;
TIPv4Box = class(TTestCase)
published
procedure TestIPv4;
end;
TMyTCPServer = class(TIdTCPServer)
private
{ TIdTCPSerevr requires a OnExecute event handler }
procedure ExecuteTCPServer(AContext: TIdContext);
end;
implementation
uses
IdTCPClient,
IdException,
IdServerIOHandlerStack,
IdIOHandlerStack,
IdGlobal;
procedure TIPv4Box.TestIPv4;
var
LServer: TMyTCPServer;
LServerIO:TIdServerIOHandlerStack;
LClient: TIdTCPClient;
{$IFDEF UseIOHandler}
LClientIO:TIdIOHandlerStack;
{$ENDIF}
begin
LServer := nil;
LServerIO := nil;
LClient := nil;
try
LServer := TMyTCPServer.Create(nil);
LServerIO := TIdServerIOHandlerStack.Create(nil);
LServer.IOHandler := LServerIO;
LServer.OnExecute := LServer.ExecuteTCPServer;
with LServer.Bindings.Add do
begin
IP := '0.0.0.0';
Port := 12987;
IPVersion := Id_IPv4;
end;
try
LServer.Active:=true;
except on e: EIdException do
Check(false, 'The TIdTCPServer failed to start: '+e.message);
end;
Check(LServer.Active, 'The TIdTCPServer doesn''t seem to be running, but no exception occured?'); // BGO: Just to be sure
LClient := TIdTCPClient.Create(nil);
{$IFNDEF UseIOHandler}
LClient.Host := '127.0.0.1';
LClient.Port := 12987;
LClient.IPVersion := Id_IPv4;
{$ELSE}
LClientIO := TIdIOHandlerStack.Create(nil);
LClientIO.Host := '127.0.0.1';
LClientIO.Port := 12987;
LClientIO.IPVersion := Id_IPv4;
LClient.IOHandler := LClientIO;
{$ENDIF}
try
LClient.Connect;
except
on e: EIdException do
Fail('The TIdTCPClient failed to connect: '+e.message);
end;
finally
FreeAndNil( LServer );
FreeAndNil( LServerIO );
FreeAndNil( LClient );
{$IFDEF UseIOHandler}
FreeAndNil( LClientIO );
{$ENDIF}
end;
end;
{ TMyTCPServer }
procedure TMyTCPServer.ExecuteTCPServer(AContext: TIdContext);
begin
// do nothing
end;
initialization
// TIndyBox.RegisterBox(TIPv4Box, 'IPv4 Support', 'Misc');
ProjectRegisterTest(gsIdProductName + ' v' + gsIdProductVersion, 'IPv4 Support', TIPv4Box.Suite);
// TestFramework.RegisterTest('IPv4 Support', TIPv4Box.Suite);
end.
More information about the Lazarus
mailing list