Ver código fonte

* TcpClient.cs: Fixed SetTcpClient() to pass through to the Client
property, which now sets stream to null (it's set by GetStream()). This
should make GetStream() work on a TcpClient which has had the socket set
by assignment to the Client property, not only one that has been created
by TcpListener.AcceptTcpClient().

svn path=/trunk/mcs/; revision=8753

Phillip Pearson 23 anos atrás
pai
commit
3eaf9fc66a

+ 8 - 0
mcs/class/System/System.Net.Sockets/ChangeLog

@@ -1,3 +1,11 @@
+2002-11-03  Phillip Pearson  <[email protected]>
+
+	* TcpClient.cs: Fixed SetTcpClient() to pass through to the Client 
+	property, which now sets stream to null (it's set by GetStream()).  This 
+	should make GetStream() work on a TcpClient which has had the socket set 
+	by assignment to the Client property, not only one that has been created 
+	by TcpListener.AcceptTcpClient().
+
 2002-10-08  Dick Porter  <[email protected]>
 
 	* Socket.cs: 

+ 12 - 4
mcs/class/System/System.Net.Sockets/TcpClient.cs

@@ -91,7 +91,10 @@ namespace System.Net.Sockets
 		protected Socket Client
 		{
 			get { return client; }
-			set { client = value; }
+			set {
+				client = value;
+				stream = null;
+			}
 		}
 
 		/// <summary>
@@ -102,8 +105,7 @@ namespace System.Net.Sockets
 		/// <param name="s"></param>
 		internal void SetTcpClient (Socket s) 
 		{
-			client = s;
-			stream = new NetworkStream (client, true);
+			Client = s;
 		}
 		
 		/// <summary>
@@ -325,7 +327,13 @@ namespace System.Net.Sockets
 		/// connection socket</returns>
 		public NetworkStream GetStream()
 		{
-			try { return stream; }
+			try {
+				if (stream == null)
+				{
+					stream = new NetworkStream (client, true);
+				}
+				return stream;
+			}
 			finally { CheckDisposed (); }
 		}