Browse Source

2004-12-03 Gonzalo Paniagua Javier <[email protected]>

	* NetworkStream.cs: Write should ensure that writes all the contents
	of the buffer. Fixes bug #70123. Besos para Miguelito.


svn path=/trunk/mcs/; revision=36989
Gonzalo Paniagua Javier 21 years ago
parent
commit
81996fee78

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

@@ -1,3 +1,8 @@
+2004-12-03 Gonzalo Paniagua Javier <[email protected]>
+
+	* NetworkStream.cs: Write should ensure that writes all the contents
+	of the buffer. Fixes bug #70123. Besos para Miguelito.
+
 2004-10-14  Dick Porter  <[email protected]>
 
 	* Socket.cs (Sockets ): Set Accept()ed socket blocking status to

+ 6 - 3
mcs/class/System/System.Net.Sockets/NetworkStream.cs

@@ -163,8 +163,8 @@ namespace System.Net.Sockets
 
 			try {
 				retval = socket.BeginReceive (buffer, offset, size, 0, callback, state);
-			} catch {
-				throw new IOException ("BeginReceive failure");
+			} catch (Exception e) {
+				throw new IOException ("BeginReceive failure", e);
 			}
 
 			return retval;
@@ -310,7 +310,10 @@ namespace System.Net.Sockets
 				throw new ArgumentOutOfRangeException("offset+size exceeds the size of buffer");
 
 			try {
-				socket.Send (buffer, offset, size, 0);
+				int count = 0;
+				while (size - count > 0) {
+					count += socket.Send (buffer, offset + count, size - count, 0);
+				}
 			} catch (Exception e) {
 				throw new IOException ("Write failure", e); 
 			}