tcp - Weird issue with TcpClient.Connected=true when tcpclient and relative stream have been closed C# -
let's have 2 applications, server , client. i'm debugging them @ same time in 2 instances of visual studio 2010. let's on client side call:
_reader.close(); //binaryreader _writer.close(); //binarywriter _ssl.close(); //sslstream taken _stream _stream.close(); //networkstream _client.getstream(); _client.close(); //tcpclient
and i've checked through debugger code executed. after this, trigger, other instructions, closure of client application, infact visual studio exits debug mode , goes standard mode.
in server application, since connection closed, pending _reader.read() fails, triggering exception handled in try/catch. this, according tcpclient.connected remarks should update value of tcpclient.connected accordingly.
this doesn't happen: different thread in server keeps checking _client.connected it's still true.
you should note that:
1) if close client using "stop" button works seamlessly, _client.connected becomes false
2) don't know may relevant, server listens on 127.0.0.1 , client connects 127.0.0.1 since i'm debugging these 2 apps on single pc
the connected property updated when call write or read.
Comments
Post a Comment