N
Nicolas
Hello,
I have to read data from a Stream class whose underlying type is a
NetworkStream class.
It works but when the client disconnects, no Exception is thrown. It
returns 0 but it should throw an Exception too.. I can't get it to work.
Thank you if you can provide some infos about this. BTW I use .net 2.0,
but it shouldn't be relevant in this case...
CODE ->
byte[] red_flow;
int red;
red = 0;
red_flow = new byte[4096];
try
{
if ((red = someStream.Read(red_flow, 0, red_flow.Length)) == 0)
{
Console.WriteLine("disconnected");
return;
}
}
catch
{
Console.WriteLine("disconnected");
return;
}
Console.WriteLine("not disconnected");
return;
I have to read data from a Stream class whose underlying type is a
NetworkStream class.
It works but when the client disconnects, no Exception is thrown. It
returns 0 but it should throw an Exception too.. I can't get it to work.
Thank you if you can provide some infos about this. BTW I use .net 2.0,
but it shouldn't be relevant in this case...
CODE ->
byte[] red_flow;
int red;
red = 0;
red_flow = new byte[4096];
try
{
if ((red = someStream.Read(red_flow, 0, red_flow.Length)) == 0)
{
Console.WriteLine("disconnected");
return;
}
}
catch
{
Console.WriteLine("disconnected");
return;
}
Console.WriteLine("not disconnected");
return;