Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-11

KOL socketclient object

12 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Yury Sidorov
to Kutlay Ozger

From: Kutlay Ozger

How may I use Socketclient (or another socket or TCP components like lNet) component with KOL? How do I convert?

You can use 3rd party non visual (LCL is not used) components like lNet without any modifications. Just create needed objects in runtime and set all needed properties/events in runtime.

Yury Sidorov.

Reply by email

Aleš Katona
to Kutlay Ozger: How may I use Socketclient (or another socket or TCP components like lNet) component with…

lNet non-visual can indeed be used anywhere BUT you need to understand the concept of .CallAction (see docs at http://members.chello.sk/ales/docs and homepage at http://lnet.wordpress.com) and that you'll need to integrate it into the main loop somehow (either directly, or if you're using some sort of widgetset then it might be possible to use that, but that's a bit more complicated).

Ale? Katona

Reply by email

Usuario Anónimo
to Aleš Katona

If I put the unit lNetComponents in the uses onto KOL-CE application I get the run-time error: Project raised exception class 'External: SIGSEGV'.

Why?

This is my code:

{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit Unit2;
interface
uses Windows, Messages, KOL, lNetComponents {place your units here->}
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs,
Graphics;
{$ELSE} ; {$ENDIF}
type
  { TForm2 }
  {$I MCKfakeClasses.inc}
  {$IFDEF KOLCLASSES} TForm2 = class; PForm2 = TForm2; {$ELSE OBJECTS}
PForm2 = ^TForm2; {$ENDIF CLASSES/OBJECTS}
  TForm2 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF
LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
  Button1: TKOLButton;
  Form: PControl;
  KOLForm1: TKOLForm;
  procedure Button1Click(Sender: PObj);
  private
  { private declarations }
  LTCPComponent1: TLTCPComponent;
  public
  { public declarations }
  end;
var
  Form2 {$IFDEF KOL_MCK} : PForm2 {$ELSE} : TForm2 {$ENDIF} ;

Thank you very much, best regards.

2008/11/11 Ale? Katona

Show quoted text 15 lines
lNet non-visual can indeed be used anywhere BUT you need to understand the concept of .CallAction (see docs at http://members.chello.sk/ales/docs and homepage at http://lnet.wordpress.com) and that you'll need to integrate it into the main loop somehow (either directly, or if you're using some sort of widgetset then it might be possible to use that, but that's a bit more complicated). -- Ale? Katona _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081111/d6bfe43c/attachment-0001.html

Reply by email

Kutlay Ozger
to Usuario Anónimo

You must create components dynamically.
It works like this.

procedure TForm1.FormCreate(Sender: TObject);
begin
    LTCPComponent1:=TLTCPComponent.Create(nil);
end;

Do not add component on form.

2008/11/11 Usuario An?nimo

Show quoted text 71 lines
If I put the unit lNetComponents in the uses onto KOL-CE application I get the run-time error: Project raised exception class 'External: SIGSEGV'. Why? This is my code: { KOL MCK } // Do not remove this line! {$DEFINE KOL_MCK} {$ifdef FPC} {$mode delphi} {$endif} unit Unit2; interface uses Windows, Messages, KOL, lNetComponents {place your units here->} {$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics; {$ELSE} ; {$ENDIF} type { TForm2 } {$I MCKfakeClasses.inc} {$IFDEF KOLCLASSES} TForm2 = class; PForm2 = TForm2; {$ELSE OBJECTS} PForm2 = ^TForm2; {$ENDIF CLASSES/OBJECTS} TForm2 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF}) Button1: TKOLButton; Form: PControl; KOLForm1: TKOLForm; procedure Button1Click(Sender: PObj); private { private declarations } LTCPComponent1: TLTCPComponent; public { public declarations } end; var Form2 {$IFDEF KOL_MCK} : PForm2 {$ELSE} : TForm2 {$ENDIF} ; Thank you very much, best regards. 2008/11/11 Ale? Katona lNet non-visual can indeed be used anywhere BUT you need to understand the > concept of .CallAction (see docs at http://members.chello.sk/ales/docsand homepage at > http://lnet.wordpress.com) and that you'll need to integrate it into the > main loop somehow (either directly, or if you're using some sort of > widgetset then it might be possible to use that, but that's a bit more > complicated). > > -- > Ale? Katona > > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Kutlay ?zger -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081111/09a6afdd/attachment.html

Reply by email

Usuario Anónimo
to Kutlay Ozger

I create the component dynamically (I do not drop the component onto the form) but if I put the unit "lNetComponents" in the uses I get the run-time error: Project raised exception class 'External: SIGSEGV'.

Why?

This is my code:

{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit Unit2;
interface
uses Windows, Messages, KOL, lNetComponents {place your units here->}
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs,
Graphics;
{$ELSE} ; {$ENDIF}
type
  { TForm2 }
  {$I MCKfakeClasses.inc}
  {$IFDEF KOLCLASSES} TForm2 = class; PForm2 = TForm2; {$ELSE OBJECTS}
PForm2 = ^TForm2; {$ENDIF CLASSES/OBJECTS}
  TForm2 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF
LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
  Button1: TKOLButton;
  Form: PControl;
  KOLForm1: TKOLForm;
  procedure Button1Click(Sender: PObj);
  private
  { private declarations }
  LTCPComponent1: TLTCPComponent;
  public
  { public declarations }
  end;
var
  Form2 {$IFDEF KOL_MCK} : PForm2 {$ELSE} : TForm2 {$ENDIF} ;

2008/11/11 Kutlay Ozger

Show quoted text 96 lines
You must create components dynamically. It works like this. procedure TForm1.FormCreate(Sender: TObject); begin LTCPComponent1:=TLTCPComponent.Create(nil); end; Do not add component on form. 2008/11/11 Usuario An?nimo > If I put the unit lNetComponents in the uses onto KOL-CE application I get > the run-time error: Project raised exception class 'External: SIGSEGV'. > > Why? > > > > This is my code: > > { KOL MCK } // Do not remove this line! > {$DEFINE KOL_MCK} > {$ifdef FPC} {$mode delphi} {$endif} > unit Unit2; > > interface > > uses Windows, Messages, KOL, lNetComponents {place your units here->} > {$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, > Graphics; > {$ELSE} ; {$ENDIF} > > type > > { TForm2 } > > {$I MCKfakeClasses.inc} > {$IFDEF KOLCLASSES} TForm2 = class; PForm2 = TForm2; {$ELSE OBJECTS} > PForm2 = ^TForm2; {$ENDIF CLASSES/OBJECTS} > TForm2 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF > LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF}) > Button1: TKOLButton; > Form: PControl; > KOLForm1: TKOLForm; > procedure Button1Click(Sender: PObj); > private > { private declarations } > LTCPComponent1: TLTCPComponent; > public > { public declarations } > end; > > var > Form2 {$IFDEF KOL_MCK} : PForm2 {$ELSE} : TForm2 {$ENDIF} ; > > Thank you very much, best regards. > > 2008/11/11 Ale? Katona > >> lNet non-visual can indeed be used anywhere BUT you need to understand >> the concept of .CallAction (see docs at >> http://members.chello.sk/ales/docs and homepage at >> http://lnet.wordpress.com) and that you'll need to integrate it into the >> main loop somehow (either directly, or if you're using some sort of >> widgetset then it might be possible to use that, but that's a bit more >> complicated). >> >> -- >> Ale? Katona >> >> _______________________________________________ >> Lazarus mailing list >> >> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus >> > > > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > > -- Kutlay ?zger _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081111/0ea4f586/attachment-0001.html

Reply by email

Usuario Anónimo
to Usuario Anónimo

@Kutlay Ozger. You can run a KOL-CE application with lNet?

2008/11/11 Usuario An?nimo

Show quoted text 146 lines
I create the component dynamically (I do not drop the component onto the form) but if I put the unit "lNetComponents" in the uses I get the run-time error: Project raised exception class 'External: SIGSEGV'. Why? This is my code: { KOL MCK } // Do not remove this line! {$DEFINE KOL_MCK} {$ifdef FPC} {$mode delphi} {$endif} unit Unit2; interface uses Windows, Messages, KOL, lNetComponents {place your units here->} {$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics; {$ELSE} ; {$ENDIF} type { TForm2 } {$I MCKfakeClasses.inc} {$IFDEF KOLCLASSES} TForm2 = class; PForm2 = TForm2; {$ELSE OBJECTS} PForm2 = ^TForm2; {$ENDIF CLASSES/OBJECTS} TForm2 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF}) Button1: TKOLButton; Form: PControl; KOLForm1: TKOLForm; procedure Button1Click(Sender: PObj); private { private declarations } LTCPComponent1: TLTCPComponent; public { public declarations } end; var Form2 {$IFDEF KOL_MCK} : PForm2 {$ELSE} : TForm2 {$ENDIF} ; 2008/11/11 Kutlay Ozger > You must create components dynamically. > It works like this. > > procedure TForm1.FormCreate(Sender: TObject); > begin > LTCPComponent1:=TLTCPComponent.Create(nil); > end; > > Do not add component on form. > > > 2008/11/11 Usuario An?nimo > >> If I put the unit lNetComponents in the uses onto KOL-CE application I >> get the run-time error: Project raised exception class 'External: SIGSEGV'. >> >> Why? >> >> >> >> This is my code: >> >> { KOL MCK } // Do not remove this line! >> {$DEFINE KOL_MCK} >> {$ifdef FPC} {$mode delphi} {$endif} >> unit Unit2; >> >> interface >> >> uses Windows, Messages, KOL, lNetComponents {place your units here->} >> {$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, >> Graphics; >> {$ELSE} ; {$ENDIF} >> >> type >> >> { TForm2 } >> >> {$I MCKfakeClasses.inc} >> {$IFDEF KOLCLASSES} TForm2 = class; PForm2 = TForm2; {$ELSE OBJECTS} >> PForm2 = ^TForm2; {$ENDIF CLASSES/OBJECTS} >> TForm2 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF >> LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF}) >> Button1: TKOLButton; >> Form: PControl; >> KOLForm1: TKOLForm; >> procedure Button1Click(Sender: PObj); >> private >> { private declarations } >> LTCPComponent1: TLTCPComponent; >> public >> { public declarations } >> end; >> >> var >> Form2 {$IFDEF KOL_MCK} : PForm2 {$ELSE} : TForm2 {$ENDIF} ; >> >> Thank you very much, best regards. >> >> 2008/11/11 Ale? Katona >> >>> lNet non-visual can indeed be used anywhere BUT you need to understand >>> the concept of .CallAction (see docs at >>> http://members.chello.sk/ales/docs and homepage at >>> http://lnet.wordpress.com) and that you'll need to integrate it into >>> the main loop somehow (either directly, or if you're using some sort of >>> widgetset then it might be possible to use that, but that's a bit more >>> complicated). >>> >>> -- >>> Ale? Katona >>> >>> _______________________________________________ >>> Lazarus mailing list >>> >>> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus >>> >> >> >> _______________________________________________ >> Lazarus mailing list >> >> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus >> >> > > > -- > Kutlay ?zger > > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081111/bb3fb0f8/attachment.html

Reply by email

Aleš Katona
to Usuario Anónimo

lNetComponents is the "visual" lNet package and it tries to make a LCLEventer which tries to integrate into LCL/widgetset main loop (see my callaction note from before).

Obviously this will fail without LCL, although I'd expect a compile-time error, not a runtime error.

If you get the time, can you give me a backtrace? lNetComponents uses the lclnet unit which depends on LCL units so it shouldn't have compiled.

Ale? Katona

Reply by email

John vd Waeter
to Aleš Katona
Ale? Katona wrote 6 lines
lNetComponents is the "visual" lNet package and it tries to make a LCLEventer which tries to integrate into LCL/widgetset main loop (see my callaction note from before). Obviously this will fail without LCL, although I'd expect a compile-time error, not a runtime error. If you get the time, can you give me a backtrace? lNetComponents uses the lclnet unit which depends on LCL units so it shouldn't have compiled.

Do not use the lNET visual components on a KOL project. Instead create them at runtime, like myTCP := tlTCP.Create(nil) See the "console" examples on how to use them.
The code inside the components does not get triggered by LCL-events. So you have to trigger the code yourself by frequently calling the CallAction method.

GL!
John

Reply by email

Bogusław Brandys
to Aleš Katona: lNetComponents is the "visual" lNet package and it tries to make a LCLEventer which tries…

Ale? Katona pisze:

Show quoted text 6 lines
lNetComponents is the "visual" lNet package and it tries to make a LCLEventer which tries to integrate into LCL/widgetset main loop (see my callaction note from before). Obviously this will fail without LCL, although I'd expect a compile-time error, not a runtime error. If you get the time, can you give me a backtrace? lNetComponents uses the lclnet unit which depends on LCL units so it shouldn't have compiled.

Try to use synapse library ported to KOL.

Boguslaw

Reply by email

User
to Bogusław Brandys

I can?t assign the callbacks:

{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit ModuloDatos2;
interface
uses Windows, Messages, KOL {place your units here->}, lNet
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs,
Graphics;
{$ELSE} ; {$ENDIF}
type
  { TForm3 }
  {$I MCKfakeClasses.inc}
  {$IFDEF KOLCLASSES} TForm3 = class; PForm3 = TForm3; {$ELSE OBJECTS}
PForm3 = ^TForm3; {$ENDIF CLASSES/OBJECTS}
  TForm3 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF
LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
    Form: PControl;
    KOLForm3: TKOLForm;
    procedure KOLForm3BeforeCreateWindow(Sender: PObj);
    procedure OnDs(aSocket: TLSocket);
    procedure OnRe(aSocket: TLSocket);
    procedure OnEr(const msg: string; aSocket: TLSocket);
  private
    { private declarations }
  public
    { public declarations }
    Conexion: TLTcp;
  end;
var
  Form3 {$IFDEF KOL_MCK} : PForm3 {$ELSE} : TForm3 {$ENDIF} ;
{$IFDEF KOL_MCK}
procedure NewForm3( var Result: PForm3; AParent: PControl );
{$ENDIF}
implementation
{$IFDEF KOL_MCK}
{$I modulodatos2_1.inc}
{$ENDIF}

{ TForm3 }

procedure TForm3.KOLForm3BeforeCreateWindow(Sender: PObj);
begin
  Conexion := TLTCP.Create(nil); // create new TCP connection with no parent
component
  Conexion.OnError := @OnEr; // assign callbacks
  Conexion.OnReceive := @OnRe;
  Conexion.OnDisconnect := @OnDs;
  Conexion.Timeout := 100; // responsive enough, but won't hog cpu
  ShowMessage('Componente para la conexi?n creado');
end;
procedure TForm3.OnDs(aSocket: TLSocket);
begin
  ShowMessage('Lost connection');
end;
procedure TForm3.OnRe(aSocket: TLSocket);
var
  s: string;
begin
  if aSocket.GetMessage(s) > 0 then
    ShowMessage(s);
end;
procedure TForm3.OnEr(const msg: string; aSocket: TLSocket);
begin
  ShowMessage(msg); // if error occured, write it
end;
initialization
{$IFNDEF KOL_MCK} {$I modulodatos2.lrs} {$ENDIF}
end.

I get the error:

ModuloDatos2.pas(48,28) Error: Variable identifier expected

Anybody help me?
Best regards.

2008/11/12 Bogus?aw Brandys

Show quoted text 22 lines
Ale? Katona pisze: > lNetComponents is the "visual" lNet package and it tries to make a LCLEventer which tries to integrate into LCL/widgetset main loop (see my callaction note from before). > > Obviously this will fail without LCL, although I'd expect a compile-time error, not a runtime error. > > If you get the time, can you give me a backtrace? lNetComponents uses the lclnet unit which depends on LCL units so it shouldn't have compiled. > Try to use synapse library ported to KOL. Boguslaw _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081209/36aa2591/attachment.html

Reply by email

User
to User

The solution:

Delphi mode is used for MCK generated source files.

Assign event without @
Conexion.OnError := OnEr;

2008/12/9 User

Show quoted text 116 lines
I can?t assign the callbacks: { KOL MCK } // Do not remove this line! {$DEFINE KOL_MCK} {$ifdef FPC} {$mode delphi} {$endif} unit ModuloDatos2; interface uses Windows, Messages, KOL {place your units here->}, lNet {$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics; {$ELSE} ; {$ENDIF} type { TForm3 } {$I MCKfakeClasses.inc} {$IFDEF KOLCLASSES} TForm3 = class; PForm3 = TForm3; {$ELSE OBJECTS} PForm3 = ^TForm3; {$ENDIF CLASSES/OBJECTS} TForm3 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF}) Form: PControl; KOLForm3: TKOLForm; procedure KOLForm3BeforeCreateWindow(Sender: PObj); procedure OnDs(aSocket: TLSocket); procedure OnRe(aSocket: TLSocket); procedure OnEr(const msg: string; aSocket: TLSocket); private { private declarations } public { public declarations } Conexion: TLTcp; end; var Form3 {$IFDEF KOL_MCK} : PForm3 {$ELSE} : TForm3 {$ENDIF} ; {$IFDEF KOL_MCK} procedure NewForm3( var Result: PForm3; AParent: PControl ); {$ENDIF} implementation {$IFDEF KOL_MCK} {$I modulodatos2_1.inc} {$ENDIF} { TForm3 } procedure TForm3.KOLForm3BeforeCreateWindow(Sender: PObj); begin Conexion := TLTCP.Create(nil); // create new TCP connection with no parent component Conexion.OnError := @OnEr; // assign callbacks Conexion.OnReceive := @OnRe; Conexion.OnDisconnect := @OnDs; Conexion.Timeout := 100; // responsive enough, but won't hog cpu ShowMessage('Componente para la conexi?n creado'); end; procedure TForm3.OnDs(aSocket: TLSocket); begin ShowMessage('Lost connection'); end; procedure TForm3.OnRe(aSocket: TLSocket); var s: string; begin if aSocket.GetMessage(s) > 0 then ShowMessage(s); end; procedure TForm3.OnEr(const msg: string; aSocket: TLSocket); begin ShowMessage(msg); // if error occured, write it end; initialization {$IFNDEF KOL_MCK} {$I modulodatos2.lrs} {$ENDIF} end. I get the error: ModuloDatos2.pas(48,28) Error: Variable identifier expected Anybody help me? Best regards. 2008/11/12 Bogus?aw Brandys > Ale? Katona pisze: > > lNetComponents is the "visual" lNet package and it tries to make a > LCLEventer which tries to integrate into LCL/widgetset main loop (see my > callaction note from before). > > > > Obviously this will fail without LCL, although I'd expect a compile-time > error, not a runtime error. > > > > If you get the time, can you give me a backtrace? lNetComponents uses > the lclnet unit which depends on LCL units so it shouldn't have compiled. > > > > > Try to use synapse library ported to KOL. > > > Boguslaw > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081210/7334b18a/attachment.html

Reply by email