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);
  • 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. – Stephen Cleary Aug 23 '16 at 02:10
  • Thanks Stephen. I have restructured my code as per your suggestion. – bharat aghera Oct 25 '16 at 10:24

0 Answers0