Re: How to catch error (or exit) when Receive hang - WeOnlyDo Discussion board

Re: How to catch error (or exit) when Receive hang (General questions)

by wodDamir, Wednesday, November 05, 2008, 19:20 (5863 days ago) @ novanstar

Novanstar,

But you can use WaitFor method just for that purpose. Let's say that you start iperf on linux OS. It will wait until aborted by CTRL-C .

In that case, you can specify any prompt in WaitFor call, which will ofcourse timeout. But when that happens, you simply catch the error and call Receive method (or Peek) which will receive the data that was left in buffer (since WaitFor won't remove it).

When data is received, the code will proceed, and now you can send CTRL-C , which proceeds with accepting prompt.

Ofcourse, in this case, a global Timeout property has to be set to a value higher then the timeout parameter in WaitFor call.

Hope this helps.

Regards,
Damba


Complete thread: