Hi,
Why TcpClient has a method TcpClient.GetStream(), not just a read only
property?
By implementing it as a method, does that mean, each time GetStream() could
return a different stream? In other words, is that safe I only call
GetStream() once and set it to a class' variable and reuse it later?
And sometime I see TcpClient.GetStream() throws
System.InvalidOperationException: Operation not allowed on non-connected
sockets. Then I will force the user to log out.
Now I wonder is this "temporary" exception? Maybe
1: I save the stream in class variable, next time I just call Read and
wirte method, do not call GetStream() first, the exception will not occure.
2: If I catch this exception, ignore it, next time, GetStream() or
ReadByte(),Write() will work just fine.
Can someone tell if my guess right or not? It is difficult to test, since
this exception will not always occure.
Thanks,
Ryan