[Socket] Refactor Socket to make Receive(_) call Receive(_,_)
authorAndres G. Aragoneses <knocte@gmail.com>
Mon, 8 Apr 2013 09:41:56 +0000 (10:41 +0100)
committerAndres G. Aragoneses <knocte@gmail.com>
Mon, 8 Apr 2013 09:41:56 +0000 (10:41 +0100)
After previous commit, two Receive() overloads are basically the same, so
we can remove some duplicated code here by making one call the other one.

mcs/class/System/System.Net.Sockets/Socket.cs

index 490dc57e593d50c8c91c2f923775ee7511accb1e..40d72c58458a89f8a9ed26f845b907b643894159 100644 (file)
@@ -1493,23 +1493,7 @@ namespace System.Net.Sockets
 
                public int Receive (byte [] buffer)
                {
-                       if (disposed && closed)
-                               throw new ObjectDisposedException (GetType ().ToString ());
-
-                       if (buffer == null)
-                               throw new ArgumentNullException ("buffer");
-
-                       SocketError error;
-
-                       int ret = Receive_nochecks (buffer, 0, buffer.Length, SocketFlags.None, out error);
-                       
-                       if (error != SocketError.Success) {
-                               if (error == SocketError.WouldBlock && blocking) // This might happen when ReceiveTimeout is set
-                                       throw new SocketException ((int) error, "Operation timed out.");
-                               throw new SocketException ((int) error);
-                       }
-
-                       return ret;
+                       return Receive (buffer, SocketFlags.None);
                }
 
                public int Receive (byte [] buffer, SocketFlags flags)