Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   General (http://www.delphipages.com/forum/forumdisplay.php?f=2)
-   -   TcpClient connection blocks after first string (http://www.delphipages.com/forum/showthread.php?t=218672)

walker1 05-02-2019 11:30 AM

TcpClient connection blocks after first string
 
In my application I need to send JSON stings to a Raspberry PI running Python under LINUX.
My standard component runs blocking, as that is what the receiver is said to do.
(not my Python code!)

First string comes through OK, then nothing else!

If I close the connection and open it again, I can transmit another one string through.


The missing connection after first string does apparently not influence my app. I can, and do, send more strings, they 'just' don't get anywhere.
Maybe ending up in some buffer internal to the component? (Unknown)

Below is my current transmitter. It works but takes a rather long time to get things through.

Code:

procedure TFreqCtrl.SendCmd(Mode : integer; s : string);
begin
  TcpClient1.Connect;
  TcpClient1.Sendln(s);
  if Mode=0 then
    TcpClient1.Disconnect;
   
end;

I run D6 prof SP3 on Win 7 and XP. Same thing happens on both OS.

If my colleague has two Raspberry PIs talk to each other, everything gets through.

Any ideas about the blockade from Win/Delphi?

Norrit 05-03-2019 09:32 AM

Why is there a TcpClient1.Connect each time?

I would've expected something like:
if not TcpClient1.Connected then TcpClient1.Connect();

walker1 05-03-2019 11:42 AM

Quote:

Originally Posted by Norrit (Post 235256)
Why is there a TcpClient1.Connect each time?

Because, as I wrote, there is something blocking, so the following strings do not get through.


If I set the component to non-blocking nothing gets through at all!


And as the link is somehow blocked, I also seem unable to receive anything in response to a command.

Norrit 05-03-2019 02:53 PM

You don't post any code, except for TcpClient1.Connect -> WriteLn -> Disconnect
Since TcpClient1 is the only component I can see, but this has no Blocking/Unblocking methods. And your code also doesn't provide any line that tells me it has.

So, what do you mean by "My standard component runs blocking, as that is what the receiver is said to do"

And what is "The missing connection after first string does apparently not influence my app"

You provide us with half a story, a lot of guessing and I know in your head all is obvious. But I'm just a reader here without any knowledge of your code and your problem, so you'll have to be clear on what you ask.

But if you're lucky it's just something simple as not using the WriteLn and using Write instead.
Or perhaps when something send it automatically sends something back, so you need a Read(Byte) construction aswell and it locks up because you never complete the task


All times are GMT. The time now is 11:46 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.