Recent

Author Topic: Error: Identifier not found "TLSocket"  (Read 6223 times)

jolix

  • Jr. Member
  • **
  • Posts: 60
Error: Identifier not found "TLSocket"
« on: June 28, 2010, 08:08:56 am »
Hi all,

I have an I/O server module that is supposed to work with a lazarus program.
The manufacturer web page have an example in lazarus that works with lnet.
The question is, all procedures with argument (aSocket: TLSocket), Lazarus give me the follow compilation error: main.pas(29,52) Error: Identifier not found "TLSocket"

Without those procedures i can see that program and module works fine through some status leds it have and also my program detects connection because put IP and Port EditBoxes GREEN.
Right now i only have procedure TcpSocketAccept(aSocket: TLSocket), but in the near future i will need also TcpSocketReceive event and others too.

This TLSocket error don't exists if i use TLTelnetClientComponent instead of LTCPComponent.
BTW i use visual component on my form.

Some one can help me with this compilation error?

Code: [Select]
unit main;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  StdCtrls, lNetComponents, ExtCtrls, ComCtrls;

type
    TfrmMain = class(TForm)
        btnConnect: TButton;
        btnDisconnect: TButton;
        btnSendACK: TButton;
        btnExit: TButton;
        ebxIP: TEdit;
        ebxPort: TEdit;
        lblHostPort: TLabel;
        lblHostIP: TLabel;
        lbxReceive: TListBox;
        StatusBar1: TStatusBar;
        TcpSocket: TLTCPComponent;
        Timer1: TTimer;
        procedure btnConnectClick(Sender: TObject);
        procedure btnDisconnectClick(Sender: TObject);
        procedure btnExitClick(Sender: TObject);
        procedure btnSendACKClick(Sender: TObject);
        //procedure TcpSocketAccept(aSocket: TLSocket);
        // Commented because compilation error: main.pas(29,52) Error: Identifier not found "TLSocket"

    private

    public
        Constructor Create(TheOwner: TComponent); override;
        procedure FormKill(Sender: TObject);
end;

var
    frmMain: TfrmMain;

const
    CR = #13;
    LF = #10;
    CRLF = CR + LF;

implementation

{******************************************************************************
* Init
******************************************************************************}
Constructor TfrmMain.Create(TheOwner: TComponent);
var
    x: integer;
    s: string;
begin
    inherited Create(TheOwner);
    OnDestroy := @FormKill;
    ebxIP.Text := '100.0.0.10';
    ebxPort.Text := '9000';
    btnConnect.Enabled := True;
    btnDisconnect.Enabled := False;
    ebxIP.Color := clScrollBar;
    ebxPort.Color := clScrollBar;
end;

{******************************************************************************
* Close
******************************************************************************}
procedure TfrmMain.FormKill(Sender : TObject);
begin
end;

{******************************************************************************
* Close by Button
******************************************************************************}
procedure TfrmMain.btnExitClick(Sender: TObject);
begin
    Close;
end;

{******************************************************************************
* Send Acknowlodge: Server also reply ACK - Works fine
******************************************************************************}
procedure TfrmMain.btnSendACKClick(Sender: TObject);
begin
    TcpSocket.SendMessage('00' + CRLF);
    if TcpSocket.Connected then begin
        btnConnect.Enabled := False;
        btnDisconnect.Enabled := True;
        ebxIP.Color := clLime;
        ebxPort.Color := clLime;
        StatusBar1.SimpleText:='Connected to: '+ ebxIP.Text+ ':'+ ebxPort.Text;
    end;
end;

{******************************************************************************
* Open Connection by button
******************************************************************************}
procedure TfrmMain.btnConnectClick(Sender: TObject);
begin
    TcpSocket.Connect(ebxIP.Text, StrToInt(ebxPort.Text));
end;

{******************************************************************************
* Close Connection by button
******************************************************************************}
procedure TfrmMain.btnDisconnectClick(Sender: TObject);
begin
    TcpSocket.Disconnect;
    btnConnect.Enabled := True;
    btnDisconnect.Enabled := False;
    ebxIP.Color := clScrollBar;
    ebxPort.Color := clScrollBar;
    StatusBar1.SimpleText :=  'Disconnected';
end;

{******************************************************************************
* Supposed to be fired if server replies connection successfull
* This section is commented because compilation error in the
* declaration section
******************************************************************************}
{
procedure TfrmMain.TcpSocketAccept(aSocket: TLSocket);
begin
    StatusBar1.SimpleText := 'Connected';
end;
}

initialization
  {$I main.lrs}

end.

Thank you very much,
Jo

jolix

  • Jr. Member
  • **
  • Posts: 60
Re: Error: Identifier not found "TLSocket"
« Reply #1 on: June 28, 2010, 02:13:34 pm »
In reply to my self...

I forgot mentioned:

SO: XP Pro
Lazarus: 0.9.26
FPC: 2.2.2
lnet: 0.63

Error note:
The compilation error is about line //procedure TcpSocketAccept(aSocket: TLSocket); that i have to comment to get program working.

I tried Receive event with the same result. So i can't receive or send.

Any else please help me ?

Thanks,
Jo

jolix

  • Jr. Member
  • **
  • Posts: 60
(SOLVED) Re: Error: Identifier not found "TLSocket"
« Reply #2 on: June 28, 2010, 03:51:57 pm »
Hi again,

In reply to my self.
I forgot to declare "lnet" in the uses section.
Now all events i need, works fine and without compilation errors.

Jo

 

TinyPortal © 2005-2018