P
puzzlecracker
Say I this client:
try{
Socket socket= new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
/*Assume there is a connection on the other end*/
while (socket.Connected)
{
/*Do some processing*/
}
}catch (SocketException se){
Console.WriteLine(ex.Message);
} catch (Exception ex){
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("something bad happen");
}
Now, assume that connection is broken on the other end( kill -9
server). It takes several minutes for the client to determine that
something is wrong. Socket.Connected returns true even though
connection is actually BROKEN.
What is the fastest way to determine that connection doesn't exist,
once the other end breaks the link?
I would appreciate an example of your solution...
Thanks
try{
Socket socket= new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
/*Assume there is a connection on the other end*/
while (socket.Connected)
{
/*Do some processing*/
}
}catch (SocketException se){
Console.WriteLine(ex.Message);
} catch (Exception ex){
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("something bad happen");
}
Now, assume that connection is broken on the other end( kill -9
server). It takes several minutes for the client to determine that
something is wrong. Socket.Connected returns true even though
connection is actually BROKEN.
What is the fastest way to determine that connection doesn't exist,
once the other end breaks the link?
I would appreciate an example of your solution...
Thanks