0

I have created the streamSocket that received the stream of media. I want to read the stream on this socket and also want to apply readTimeout. So that I have applied it using CancellationTokenSource. As per my requirement, if I cant read within timeout limit, I dont want to close this socket. However, applying cancellation token causes the socket close in my program.

Is there any way to apply time out without closing the socket?

await socket.InputStream.ReadAsync(readBuffer, 8,     InputStreamOptions.None).AsTask(cts.Token);
2
  • Socket applications should generally be reading all the time, in a continuous loop. If you restructure your application to do so, you'll find that you won't need to cancel reads at all. Aug 23, 2016 at 2:10
  • Thanks Stephen. I have restructured my code as per your suggestion. Oct 25, 2016 at 10:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.