Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] TcpClient.Connected question

Started by tufflax Jul 27, 2007 at 2:21 AM 0 replies 750+ views
Original Post
tufflax
tufflax
Quote:
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.
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.