04-06-2021 11:35 AM
Hello,
is there a way to abort TCP-Read without closing the connection?
Example:
My VI (client) is connected to a device (server).
My client is waiting at "TCP Read" with timeout 10sec.
In a parallel loop I want to abort the "TCP Read" faster than 10sec but the connection must not be killed with "TCP Close Connection".
Solved! Go to Solution.
04-06-2021 11:37 AM
Can you make the timeout shorter?
04-06-2021 12:12 PM
@Greil wrote:
Hello,
is there a way to abort TCP-Read without closing the connection?
Example:
My VI (client) is connected to a device (server).
My client is waiting at "TCP Read" with timeout 10sec.
In a parallel loop I want to abort the "TCP Read" faster than 10sec but the connection must not be killed with "TCP Close Connection".
Make a FOR loop around the TCP read where the amount of loops it runs divides the timeout. So instead of waiting 10 seconds 1 time, wait 1 second 10 times, or 0.1 second 100 times. Then just add a conditional terminal to the FOR loop to allow early termination via some form of messaging, or upon receipt of the expected message, and add a "Clear error" that clears a timeout error each loop (but does not clear other error types).
04-07-2021 05:28 AM
The reason why the "TCP Close Connection" is 'no option' is because the device needs always a "stop" command before closing the connection (even on error), otherwise the device needs a reset before next use. The reset takes much more time ... so this must be avoided.
(jup, it is a stupid device)
Thank You, but I found another approach:
In the parallel loop now I do TCP-Write "stop" and then it is safe to use "TCP Close Connection". This will abort the "TCP-Read" and the device will not hang up.
I could also write something else like *IDN?" so the read finished immediately too.
Thank You.
04-07-2021 11:06 AM