lnet TLTCPComponent not triggering receive event? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Awesome Programmer · 2015-03-16 18:09 I don't understand why this is happening. I am using  lnet TLTCPComponent to communicate through network connection. I have set up its OnReceive event. However, it just won't fire when it receives message back from another computer. What is going on? ---------------------------------------------------------------------- taazz · 2015-03-17 05:54 Quote from: reltek on March 16, 2015, 07:09:57 pm I don't understand why this is happening. I am using  lnet TLTCPComponent to communicate through network connection. I have set up its OnReceive event. However, it just won't fire when it receives message back from another computer. What is going on? WE will not understand either if you don provide something look at and grind our teeth against. In general are you sure you are not using localhost(127.0.0.1) as the listening address? do you set the listening address correctly to start with? In other news I prefer more other types of libraries so post some code and people that use it will be able to tell you what is wrong with it. ---------------------------------------------------------------------- Awesome Programmer · 2015-03-17 19:27 Hi Taazz, I wrote a test program to talk to a device connected to the Network. I simply dropped the lnet TLTCPComponent on the form and did the following. Code: [Select]type   TForm1 = class(TForm)         net1:TLTCPComponent;         Timer1:TTimer;   //Set for 30 milliseconds         procedure FormCreate(Sender:TObject);         procedure net1receive(aSocket:TLSocket);         procedure Timer1Timer(Sender:TObject);   private   public   end; procedure TForm1.FormCreate(Sender:TObject); begin       Timer1.Interval := 30; //milliseconds       net1.connect('192.168.1.31',10002);       Timer1.Enabled := true; end; procedure TForm1.net1receive(aSocket:TLSocket); var      rbyte:array[0..3] of byte; begin      asocket.Get(rbyte, sizeof(rbyte)); end; procedure TForm1.Timer1Timer(Sender:TObject); var bbyte: array[0..3] of byte; begin      bbyte[0] := $FF;      bbyte[1] :=$01;      bbyte[2] :=$03;      net1.send(bbyte, sizeof(bbyte), net1.iterator); end; This demo program works as expected. It is able to send and receive data, but when I do the same on an actual program I am working on or developing I see NO RESPONSE at all from the device. I probed its TCP/IP communication using wireshark. My pc is sending data but nothing comes back and so the OnReceive doesn't see anything to trigger on. What could be the difference between this demo code and my other program especially when I am doing exactly the SAMETHING. ---------------------------------------------------------------------- taazz · 2015-03-18 03:19 it looks like its not a problem with lnet but with the external device you are using. Things to try out. 1) make sure that the machine can accept multiple connection from the same computer. 2) make sure that one and only one program connects to the machine. 3) make sure the machine is active and responsive (aka reset it). And there my ideas end, I would need to have knowledge about the external machine and its details before trying to make any assumption of what might have gone wrong. PS. I know that you have probably done all of the above a couple of times already but with out any farther knowledge I can't help and I doubt if any one else can either. ---------------------------------------------------------------------- Awesome Programmer · 2015-03-25 15:38 Figured out why my receive event didn't trigger. I also use Synaser for Serial communication along with lNet. Somehow they interfered with each other. Once I made the serial and Network communication selectable, it is working now.