From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Client acknowledgement

Solved!
Go to solution

Hi,

 

I have written a labview code that sends file over tcp communication and recieves them and stores these files in the target folder, I did the server client communication. But my server is a loop with a stop button for ending the loop. So it will keep on running until the stop button is pressed. I would like to change it to a way that as long as client reads the data and stores it, the server should stop automatically. Which means I need some kind of acnowledgement from the client part. What can I do to achieve the same. Thanking You. 

Download All
0 Kudos
Message 1 of 8
(3,791 Views)

@vindsan wrote:

I would like to change it to a way that as long as client reads the data and stores it, the server should stop automatically. 


When you say the server should stop, what do you mean? Do you want th server to stop entirely until someone runs it again? Do you want it to just stop writing to the ports?

 

Your server code is currently listening for a TCP connection at a specific port and then writing to it once found. If you close the TCP connection in the Client VI, your Server should no longer see the connection and resume waiting again.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 8
(3,750 Views)

I want my server to stop completely. That is when the client stops the server should also stop. That is what I am trying to do. Or else when all the files have been copied to the new folder, at that time client automatically stops. So when all files are moved to the new folder I donot want the server to keep running. So I would like an acnowledgement from the client which I can use to wire to the stop condittion in the while loop in server to stop the loop. If there is something like that it would be good.

0 Kudos
Message 3 of 8
(3,743 Views)

Your server writes all of the files to the TCP connection and then closes the connection, so couldn't you just end that loop once you've written all of the files?

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 8
(3,731 Views)

U mean take the loop count and check whether it has reached the total number of loops have been reached and then stop it. That is what I am trying to do for sometime now. But I was hoping for an acknowledgement from the client side that it has indeed completed then I could stop the loop. If that is not possible, i will have to try to end the while loop from the for loop count. 

0 Kudos
Message 5 of 8
(3,725 Views)

How do I know all of the files have been written?

0 Kudos
Message 6 of 8
(3,720 Views)

Thank You. I got it. I was able to stop the while loop with number of times for loop has run. 

0 Kudos
Message 7 of 8
(3,713 Views)
Solution
Accepted by vindsan

You don't need to count the number of loops to know if the For loop ran. The For loop will always run through each iteration unless you set up a stop terminal (which you haven't).

 

What you should really do it set up a check to make sure no errors were thrown during the writing process. If no errors thrown, stop the Server loop. Like this:

At your service.png

Above, the False case (when the file already exists) outputs no error. So if all files already exist, the loop will end too.

 

P.S. you don't need to open and close the TCP connection with every For loop iteration. Just open it before the loop and close it afterwards.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 8 of 8
(3,707 Views)