Recent

Author Topic: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event  (Read 15195 times)

jolix

  • Jr. Member
  • **
  • Posts: 60
lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« on: June 28, 2010, 05:05:35 pm »
Hi,

As i understood by reading about lnet, i thought "Receive" operated by events.
Is this so?
I look to several examples and don't see nothing special to enable this event, seems me that is enough declare it in the type section.
Then in the implementation i can simply put:

Code: [Select]
procedure LTCPComponent1Receive(aSocket: TLSocket);
begin
    aSocket.GetMessage(s);
end;

The same thing happens with LTCPComponent1Accept(aSocket: TLSocket) that i think is triggered when server accepts the connection.

What i see is that those events doesn't work for me, so i wrote my own polling Receive, that is not so elegant as the event is.

What i'm doing wrong? Any else help me on this?

Thanks,
Jo

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 185
    • http://www.jvdw.nl
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #1 on: June 28, 2010, 11:44:53 pm »
Are you using the component from the LCL? Then it uses the LCL-thread to trigger its events. If not (e.g. in a console or service) you should call the CallAction method frequently, e.g. from a timer.

hth!

John


jolix

  • Jr. Member
  • **
  • Posts: 60
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #2 on: June 29, 2010, 02:26:30 am »
John,

I suppose so. I use visual lNet TCPComponent placed on my form.
When i use lNet Telnet Component all events works as supposed to.

Regards
JO

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 185
    • http://www.jvdw.nl
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #3 on: June 29, 2010, 06:07:23 am »
Hmm, I use thenm too, no problem.

Do you Connect before you send data? 
Is the onConnect event fired?
No use to send data if no connection is established...


jolix

  • Jr. Member
  • **
  • Posts: 60
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #4 on: June 29, 2010, 03:31:42 pm »
Hi John,

Before any else i like to thank you by your concern and help.

Answering to your questions:

Yes, i'm sending data after connection established.
No, onConnect is not fired. Not that neither any else like Receive, etc.
I understand that is no use to send data before connection established.

As mentioned in my last post, i have the same app using telnet component and all events works fine.
Maybe i'm wrong about it but i think the event driven mechanism is generic for all lnet components, like telnet, tcp, udp, etc. So, if telnet works, tcp should work too!?

Before you ask for, let me say my program is receiving by pooling  methode and the connection is madded by a state machine inside of a timer with 500mS TICK.

The reason is working is because my module running as a server answers to the commands i send by my program.

They are some properties or something i have to config to get event driven working ?

P.S. You know if exists a lnet user manual?

Thanks again,
Jo

jolix

  • Jr. Member
  • **
  • Posts: 60
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #5 on: June 29, 2010, 06:58:13 pm »
Ok, everything is working now as supposed to do.

For some unknown reason, the assignment of events in the Object Inspector for the TLTCPComponent, give me lnet.ppu error (source not found)???.

I try unnistall / install lnetvisual several times without results.

So i have to edit myapp.lfm and assign the events by hand as follows:

Code: [Select]
object TcpSocket: TLTCPComponent
    left = 536
    OnReceive = TcpSocketReceive <<<- line added
    OnConnect = TcpSocketConnect <<<- line added
end

Thanks

Jo

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 185
    • http://www.jvdw.nl
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #6 on: June 29, 2010, 10:09:40 pm »
Ok,

So obviously no problem with the lNet components.

If it says "file not found" then I guess something in your environment is not properly configured OR there is something wrong with your version of Lazarus. Have you tried latest snapshots?

John

jolix

  • Jr. Member
  • **
  • Posts: 60
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #7 on: June 30, 2010, 03:12:35 am »
Ho John,

About the file not found, the question is i don't know here is the right location expected by Lazarus.
Search the Lazarus root, i found this file in two different locations:
C:\lazarus\components\lnet-0.6.3\lib\i386-win32
C:\lazarus\components\lnet-0.6.3\lnet\lazaruspackage\lib\i386-win32

With "Last Snapshots" you mean last Lazarus version?
If is the case, i tried install 0.28 version several times on XP and doesn't work for me.
So, i have 0.28 version right now.

Regards,
Jo

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1945
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #8 on: June 30, 2010, 03:24:13 am »
With "Last Snapshots" you mean last Lazarus version?

"Snapshots" mean the nightly builds available here: ftp://ftp.freepascal.org/pub/lazarus/snapshots

But I have not idea if this will fix your problem.

JohnvdWaeter

  • Full Member
  • ***
  • Posts: 185
    • http://www.jvdw.nl
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #9 on: June 30, 2010, 03:26:04 am »
Yes, from the daily snapshots page on the lazarus site.

If the lNet package is installed correctly, and if there is no permissions problem, the files should have been found by the IDE.

I use lNet on both Windows and Linux, no problem.

John

jolix

  • Jr. Member
  • **
  • Posts: 60
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #10 on: July 01, 2010, 02:30:01 am »
Hi John and Theo.

Unless you want comment any else, i think this question is concluded by now.

So, let me present here a word of thanks to John and Theo and take this opportunity to explain that i am new to this things of Lazarus. My specialty is embedded systems with microcontrollers, (hardware/firmware) reason way my questions are so obvious to you but so unknown to me.

As certainly you guess, the questions i put here are related with a program to interface with those hardware things.

Thanks again.
Jo

Jake012345

  • Sr. Member
  • ****
  • Posts: 270
  • Knowledge is the key
Re: lNet - LTCPComponent1Receive(aSocket: TLSocket) Event
« Reply #11 on: May 07, 2020, 10:07:27 am »
Thanks!
That's solved my problem too. ;)

 

TinyPortal © 2005-2018