Hi,
JohnvdWaeter and Almindor,
I'm struggling with this and i'm not getting the expected result.
First:
var
MyTCP = array [1..32] of TLTCPComponent;
The compiler give me error. It only accepts:
var
MyTCP : array [1..32] of TLTCPComponent;
Like that, compiler do the job without errors but app give a runtime error when it start in a message box:
Project socket raised exception class "EClassNotFound" with message:
Class "TLTCPComponent" not found
Next, after click on OK button:
Execution stopped
procedure fcp_riseexception
Finally opens LResources unit, pointing to a line where the problem is:
try
//DebugLn('Form Stream "',ClassType.ClassName,'"');
//try
DestroyDriver:=false;
Reader := CreateLRSReader(Stream, DestroyDriver);
try
Reader.ReadRootComponent(Instance);
finally
Driver := Reader.Driver;
Reader.Free;
if DestroyDriver then
Driver.Free;
end;
This code block is part of "function InitLazResourceComponent(Instance: TComponent;"
Almindor ,
Where is supposed to place MyTCP.Parent := TfrmMain ? considering the code below, that certainly is not correct.
unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, lNetComponents, lNet, ExtCtrls, ComCtrls;
type
{ TfrmMain }
TfrmMain = class(TForm)
btnConnect: TButton;
btnDisconnect: TButton;
ebxIP: TEdit;
ebxPort: TEdit;
GroupBox1: TGroupBox;
gbxCommands: TGroupBox;
Timer1: TTimer;
procedure btnConnectClick(Sender: TObject);
procedure btnDisconnectClick(Sender: TObject);
procedure MyConnect(aSocket: TLSocket);
procedure MyDisconnect(aSocket: TLSocket);
procedure MyReceive(aSocket: TLSocket);
procedure Timer1Timer(Sender: TObject);
private
public
Constructor Create(TheOwner: TComponent); override;
procedure FormKill(Sender: TObject);
end;
var
frmMain: TfrmMain;
MyTCP : array [1..32] of TLTCPComponent;
const
CR = #13;
LF = #10;
CRLF = CR + LF;
implementation
Constructor TfrmMain.Create(TheOwner: TComponent);
var
x: integer;
begin
inherited Create(TheOwner);
OnDestroy := @FormKill;
for x := 1 to 32 do begin
MyTCP[x] := TLTCPComponent.create(nil);
MyTCP[x].OnReceive := @MyReceive;
MyTCP[x].OnConnect := @MyConnect;
MyTCP[x].OnDisconnect:= @MyDisconnect;
end;
end;
end;
Note that i suppressed all the code not significant right now.
Please remember my oop knowledges is very rude.
I have one program with only one socket running fine with LNet.
Regards,
Jo