Original Post
Quote:What I don't get is this: I only try to read (attempt to receive) if tcpClient.GetStream().DataAvailable is true, and so, can Connected in this case ever be set to false except on send attempts? I mean, how do I attempt to receive? If there isn't any DataAvailable then I can't read anything, and so I can't test if it is Connected by trying to read, because if it is not connected, then DataAvailable will never be true because it can't receive anything if it is not connected... or am I missing something here? :P
The Connected property gets the connection state of the Client socket as of the last I/O operation. When it returns false, the Client socket was either never connected, or is no longer connected. Because the Connected property only reflects the state of the connection as of the most recent operation, you should attempt to send or receive a message to determine the current state.