[Socket] Move ReceiveMessageFrom related methods to their region
authorLudovic Henry <ludovic.henry@xamarin.com>
Wed, 8 Apr 2015 21:19:17 +0000 (22:19 +0100)
committerLudovic Henry <ludovic.henry@xamarin.com>
Thu, 9 Apr 2015 13:37:18 +0000 (14:37 +0100)
mcs/class/System/System.Net.Sockets/Socket.cs

index 5ba501b400d4b618a347aa146abc0849b73c933f..fd67393e0d614358497abe3ad00cf374e055cb3f 100644 (file)
@@ -1944,38 +1944,73 @@ namespace System.Net.Sockets
 
 #endregion
 
-               void CheckRange (byte[] buffer, int offset, int size)
+#region ReceiveMessageFrom
+
+               [MonoTODO ("Not implemented")]
+               public int ReceiveMessageFrom (byte[] buffer, int offset, int size, ref SocketFlags socketFlags, ref EndPoint remoteEP, out IPPacketInformation ipPacketInformation)
                {
-                       if (offset < 0)
-                               throw new ArgumentOutOfRangeException ("offset", "offset must be >= 0");
-                       if (offset > buffer.Length)
-                               throw new ArgumentOutOfRangeException ("offset", "offset must be <= buffer.Length");
-                       if (size < 0)
-                               throw new ArgumentOutOfRangeException ("size", "size must be >= 0");
-                       if (size > buffer.Length - offset)
-                               throw new ArgumentOutOfRangeException ("size", "size must be <= buffer.Length - offset");
+                       ThrowIfDisposedAndClosed ();
+                       ThrowIfBufferNull (buffer);
+                       ThrowIfBufferOutOfRange (buffer, offset, size);
+
+                       if (remoteEP == null)
+                               throw new ArgumentNullException ("remoteEP");
+
+                       // FIXME: figure out how we get hold of the IPPacketInformation
+                       throw new NotImplementedException ();
                }
 
-               [MonoTODO]
-               public IAsyncResult BeginReceiveMessageFrom (
-                       byte[] buffer, int offset, int size,
-                       SocketFlags socketFlags, ref EndPoint remoteEP,
-                       AsyncCallback callback, object state)
+               [MonoTODO ("Not implemented")]
+               public bool ReceiveMessageFromAsync (SocketAsyncEventArgs e)
                {
-                       if (is_disposed && is_closed)
-                               throw new ObjectDisposedException (GetType ().ToString ());
+                       // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
 
-                       if (buffer == null)
-                               throw new ArgumentNullException ("buffer");
+                       ThrowIfDisposedAndClosed ();
+
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public IAsyncResult BeginReceiveMessageFrom (byte[] buffer, int offset, int size, SocketFlags socketFlags, ref EndPoint remoteEP, AsyncCallback callback, object state)
+               {
+                       ThrowIfDisposedAndClosed ();
+                       ThrowIfBufferNull (buffer);
+                       ThrowIfBufferOutOfRange (buffer, offset, size);
 
                        if (remoteEP == null)
                                throw new ArgumentNullException ("remoteEP");
 
-                       CheckRange (buffer, offset, size);
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public int EndReceiveMessageFrom (IAsyncResult asyncResult, ref SocketFlags socketFlags, ref EndPoint endPoint, out IPPacketInformation ipPacketInformation)
+               {
+                       ThrowIfDisposedAndClosed ();
+
+                       if (endPoint == null)
+                               throw new ArgumentNullException ("endPoint");
+
+                       SocketAsyncResult sockares = ValidateEndIAsyncResult (asyncResult, "EndReceiveMessageFrom", "asyncResult");
 
                        throw new NotImplementedException ();
                }
 
+#endregion
+
+               void CheckRange (byte[] buffer, int offset, int size)
+               {
+                       if (offset < 0)
+                               throw new ArgumentOutOfRangeException ("offset", "offset must be >= 0");
+                       if (offset > buffer.Length)
+                               throw new ArgumentOutOfRangeException ("offset", "offset must be <= buffer.Length");
+                       if (size < 0)
+                               throw new ArgumentOutOfRangeException ("size", "size must be >= 0");
+                       if (size > buffer.Length - offset)
+                               throw new ArgumentOutOfRangeException ("size", "size must be <= buffer.Length - offset");
+               }
+
+
                public IAsyncResult BeginSend (byte[] buffer, int offset, int size, SocketFlags socket_flags,
                                               AsyncCallback callback, object state)
                {
@@ -2230,35 +2265,8 @@ namespace System.Net.Sockets
                        return si;
                }
 #endif
-       
-
-
 
 
-               [MonoTODO]
-               public int EndReceiveMessageFrom (IAsyncResult asyncResult,
-                                                 ref SocketFlags socketFlags,
-                                                 ref EndPoint endPoint,
-                                                 out IPPacketInformation ipPacketInformation)
-               {
-                       if (is_disposed && is_closed)
-                               throw new ObjectDisposedException (GetType ().ToString ());
-
-                       if (asyncResult == null)
-                               throw new ArgumentNullException ("asyncResult");
-
-                       if (endPoint == null)
-                               throw new ArgumentNullException ("endPoint");
-
-                       SocketAsyncResult req = asyncResult as SocketAsyncResult;
-                       if (req == null)
-                               throw new ArgumentException ("Invalid IAsyncResult", "asyncResult");
-
-                       if (Interlocked.CompareExchange (ref req.EndCalled, 1, 0) == 1)
-                               throw InvalidAsyncOp ("EndReceiveMessageFrom");
-                       throw new NotImplementedException ();
-               }
-
                public void EndSendFile (IAsyncResult asyncResult)
                {
                        if (is_disposed && is_closed)
@@ -2453,39 +2461,7 @@ namespace System.Net.Sockets
                        return result;
                }
 
-               [MonoTODO ("Not implemented")]
-               public bool ReceiveMessageFromAsync (SocketAsyncEventArgs e)
-               {
-                       // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
-                       if (is_disposed && is_closed)
-                               throw new ObjectDisposedException (GetType ().ToString ());
-                       
-                       throw new NotImplementedException ();
-               }
                
-               [MonoTODO ("Not implemented")]
-               public int ReceiveMessageFrom (byte[] buffer, int offset,
-                                              int size,
-                                              ref SocketFlags socketFlags,
-                                              ref EndPoint remoteEP,
-                                              out IPPacketInformation ipPacketInformation)
-               {
-                       if (is_disposed && is_closed)
-                               throw new ObjectDisposedException (GetType ().ToString ());
-
-                       if (buffer == null)
-                               throw new ArgumentNullException ("buffer");
-
-                       if (remoteEP == null)
-                               throw new ArgumentNullException ("remoteEP");
-
-                       CheckRange (buffer, offset, size);
-
-                       /* FIXME: figure out how we get hold of the
-                        * IPPacketInformation
-                        */
-                       throw new NotImplementedException ();
-               }
 
                [MonoTODO ("Not implemented")]
                public bool SendPacketsAsync (SocketAsyncEventArgs e)