I have a simple program that uses TcpClient and SslStream to write data to a socket.
To test it I ran the program over night so my program would open the connection, write nothing for a long time, so the firewall or remote server would close the connection. This morning I took a look at TCPView and verified the connection was closed and then told my program to Write to the socket.
No exception was thrown on Write. However, the next Write did thrown this exception as expected: “System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host”
I can see why TcpClient.Connected could return True even if it really wasn’t connected, but why would Write not throw an exception on a connection that was actually closed (as verified in TCPView)?