Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2019, 11:30 AM
walker1 walker1 is offline
Junior Member
 
Join Date: Feb 2011
Posts: 12
Question 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?

Last edited by walker1; 05-03-2019 at 08:13 AM.
Reply With Quote
  #2  
Old 05-03-2019, 09:32 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,329
Default

Why is there a TcpClient1.Connect each time?

I would've expected something like:
if not TcpClient1.Connected then TcpClient1.Connect();
Reply With Quote
  #3  
Old 05-03-2019, 11:42 AM
walker1 walker1 is offline
Junior Member
 
Join Date: Feb 2011
Posts: 12
Default

Quote:
Originally Posted by Norrit View Post
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.
Reply With Quote
  #4  
Old 05-03-2019, 02:53 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,329
Default

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
Reply With Quote
Reply

Tags
connection blocks, tcpclient

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 12:27 PM.


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