12-12-2010 06:04 PM
Hi,
I've got a loop in my code that uses a TCP read function. My problem is that the loop hangs if there is no data available. What I would like to do is check if there is data available, then do the read otherwise move on to the rest of the code if no data is available and then try again on the next loop.
Thanks,
Ryan
Solved! Go to Solution.
12-12-2010 09:41 PM - edited 12-12-2010 09:42 PM
I'm guessing you are leaving the timeout terminal unwired. Wire a number to it in milliseconds. If it times out you will get an error 56. Check the error code and if it's 56 you didn't get data; if there's no error, you read data.
12-13-2010 01:21 AM
In addition to using a non-standard timeout, such as 100ms or so, one can also play with the Read Mode input of the TCP Read. Those modes are a bit pesky and not always trivial to understand but they can be useful. Read the documentation to the TCP Read function that explains these modes a bit and then start to make small experiments to verify your understanding of those operations.
12-17-2010 08:38 AM
The timeout works (don't know how I overlooked such a simple solution.) Thanks!