If i have a client that is connected to a server and if the server crashes, how can i determine, form my client, if the connection is off ? the idea is that if in my client's while
i await to read a line from my server ( String a = sr.ReadLine();
) and while the client is waiting to recieve that line , the server crashes , how do i close that thread that contains my while
?
Many have told me that in that while(alive) { .. }
I should just change the alive value to true , but if my program is currently awaiting for a line to read, it won't get to exit the while because it will be trapped at sr.ReadLine()
.
I was thinking that if i can't send a line to the server i should just close the client thread with .abort()
. Any Ideas ?