[Socket] Move Socket fields out of Socket_2_1.cs to Socket.cs
authorLudovic Henry <ludovic.henry@xamarin.com>
Wed, 8 Apr 2015 18:11:50 +0000 (19:11 +0100)
committerLudovic Henry <ludovic.henry@xamarin.com>
Wed, 8 Apr 2015 18:13:18 +0000 (19:13 +0100)
mcs/class/System/ReferenceSources/Socket.cs
mcs/class/System/System.Net.Sockets/Socket.cs
mcs/class/System/System.Net.Sockets/SocketAsyncResult.cs
mcs/class/System/System.Net.Sockets/SocketAsyncWorker.cs
mcs/class/System/System.Net.Sockets/Socket_2_1.cs
mono/metadata/socket-io.c

index d6db248b751df90cbebb49c717d577cb8aee01b7..8c1d12b8aaaeea6744f18260c9f1db19986b9c64 100644 (file)
@@ -37,10 +37,10 @@ namespace System.Net.Sockets
                // this version does not throw.
                internal void InternalShutdown (SocketShutdown how)
                {
-                       if (!connected || disposed)
+                       if (!is_connected || is_disposed)
                                return;
                        int error;
-                       Shutdown_internal (socket, how, out error);
+                       Shutdown_internal (safe_handle, how, out error);
                }
 
                internal IAsyncResult UnsafeBeginConnect (EndPoint remoteEP, AsyncCallback callback, object state)
@@ -86,7 +86,7 @@ namespace System.Net.Sockets
 
                internal void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue, bool silent)
                {
-                       if (disposed && closed) {
+                       if (is_disposed && is_closed) {
                                if (silent)
                                        return;
                                throw new ObjectDisposedException (GetType ().ToString ());
@@ -94,7 +94,7 @@ namespace System.Net.Sockets
 
                        int error;
 
-                       SetSocketOption_internal (socket, optionLevel, optionName, null,
+                       SetSocketOption_internal (safe_handle, optionLevel, optionName, null,
                                null, optionValue, out error);
 
                        if (!silent && error != 0)
index b6baf613e78d0bb5ffd84a93977aabd4c72982a4..740232f0db1935f1edd8d92a854048577950d20c 100644 (file)
@@ -50,11 +50,52 @@ namespace System.Net.Sockets
 {
        public partial class Socket : IDisposable
        {
-               private bool islistening;
-               private bool useoverlappedIO;
-               private const int SOCKET_CLOSED = 10004;
+               const int SOCKET_CLOSED_CODE = 10004;
+               const string TIMEOUT_EXCEPTION_MSG = "A connection attempt failed because the connected party did not properly respond" +
+                       "after a period of time, or established connection failed because connected host has failed to respond";
 
-               private static readonly string timeout_exc_msg = "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond";
+               /*
+                *      These two fields are looked up by name by the runtime, don't change
+                *  their name without also updating the runtime code.
+                */
+               static int ipv4_supported = -1;
+               static int ipv6_supported = -1;
+
+               /* true if we called Close_internal */
+               bool is_closed;
+
+               bool is_listening;
+               bool use_overlapped_io;
+
+               int linger_timeout;
+
+               /* the field "safe_handle" is looked up by name by the runtime */
+               SafeSocketHandle safe_handle;
+
+               AddressFamily address_family;
+               SocketType socket_type;
+               ProtocolType protocol_type;
+
+               /*
+                * This EndPoint is used when creating new endpoints. Because
+                * there are many types of EndPoints possible,
+                * seed_endpoint.Create(addr) is used for creating new ones.
+                * As such, this value is set on Bind, SentTo, ReceiveFrom,
+                * Connect, etc.
+                */
+               internal EndPoint seed_endpoint = null;
+
+               internal Queue readQ = new Queue (2);
+               internal Queue writeQ = new Queue (2);
+
+               internal bool is_blocking = true;
+               internal bool is_bound;
+
+               /* When true, the socket was connected at the time of the last IO operation */
+               internal bool is_connected;
+
+               internal bool is_disposed;
+               internal bool connect_in_progress;
 
                static void AddSockets (List<Socket> sockets, IList list, string name)
                {
@@ -125,9 +166,9 @@ namespace System.Net.Sockets
                                        continue;
                                }
 
-                               if (mode == 1 && currentList == checkWrite && !sock.connected) {
+                               if (mode == 1 && currentList == checkWrite && !sock.is_connected) {
                                        if ((int) sock.GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error) == 0)
-                                               sock.connected = true;
+                                               sock.is_connected = true;
                                }
 
                                // Remove non-signaled sockets before the current one
@@ -148,8 +189,8 @@ namespace System.Net.Sockets
                        socket_type=type;
                        protocol_type=proto;
                        
-                       socket=sock;
-                       connected=true;
+                       safe_handle = sock;
+                       is_connected = true;
                }
 
                private void SocketDefaults ()
@@ -182,18 +223,18 @@ namespace System.Net.Sockets
                public Socket (SocketInformation socketInformation)
                {
                        var options = socketInformation.Options;
-                       islistening = (options & SocketInformationOptions.Listening) != 0;
-                       connected   = (options & SocketInformationOptions.Connected) != 0;
-                       blocking    = (options & SocketInformationOptions.NonBlocking) == 0;
-                       useoverlappedIO = (options & SocketInformationOptions.UseOnlyOverlappedIO) != 0;
+                       is_listening      = (options & SocketInformationOptions.Listening) != 0;
+                       is_connected      = (options & SocketInformationOptions.Connected) != 0;
+                       is_blocking       = (options & SocketInformationOptions.NonBlocking) == 0;
+                       use_overlapped_io = (options & SocketInformationOptions.UseOnlyOverlappedIO) != 0;
 
                        var result = Mono.DataConverter.Unpack ("iiiil", socketInformation.ProtocolInformation, 0);
                        
                        address_family = (AddressFamily) (int) result [0];
                        socket_type = (SocketType) (int) result [1];
                        protocol_type = (ProtocolType) (int) result [2];
-                       isbound = (ProtocolType) (int) result [3] != 0;
-                       socket = new SafeSocketHandle ((IntPtr) (long) result [4], true);
+                       is_bound = (ProtocolType) (int) result [3] != 0;
+                       safe_handle = new SafeSocketHandle ((IntPtr) (long) result [4], true);
                        SocketDefaults ();
                }
 #endif
@@ -216,12 +257,12 @@ namespace System.Net.Sockets
 
                public int Available {
                        get {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
 
                                int ret, error;
                                
-                               ret = Available_internal(socket, out error);
+                               ret = Available_internal (safe_handle, out error);
 
                                if (error != 0)
                                        throw new SocketException (error);
@@ -233,7 +274,7 @@ namespace System.Net.Sockets
 
                public bool DontFragment {
                        get {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
 
@@ -250,7 +291,7 @@ namespace System.Net.Sockets
                                return(dontfragment);
                        }
                        set {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
 
@@ -266,7 +307,7 @@ namespace System.Net.Sockets
 
                public bool EnableBroadcast {
                        get {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
 
@@ -277,7 +318,7 @@ namespace System.Net.Sockets
                                return((int)(GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Broadcast)) != 0);
                        }
                        set {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
 
@@ -291,17 +332,17 @@ namespace System.Net.Sockets
                
                public bool ExclusiveAddressUse {
                        get {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
 
                                return((int)(GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse)) != 0);
                        }
                        set {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
-                               if (isbound) {
+                               if (is_bound) {
                                        throw new InvalidOperationException ("Bind has already been called for this socket");
                                }
                                
@@ -311,20 +352,20 @@ namespace System.Net.Sockets
                
                public bool IsBound {
                        get {
-                               return(isbound);
+                               return(is_bound);
                        }
                }
                
                public LingerOption LingerState {
                        get {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
 
                                return((LingerOption)GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Linger));
                        }
                        set {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
                                
@@ -336,7 +377,7 @@ namespace System.Net.Sockets
                
                public bool MulticastLoopback {
                        get {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
 
@@ -367,7 +408,7 @@ namespace System.Net.Sockets
                                return(multicastloopback);
                        }
                        set {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
 
@@ -399,16 +440,16 @@ namespace System.Net.Sockets
                [MonoTODO ("This doesn't do anything on Mono yet")]
                public bool UseOnlyOverlappedIO {
                        get {
-                               return(useoverlappedIO);
+                               return use_overlapped_io;
                        }
                        set {
-                               useoverlappedIO = value;
+                               use_overlapped_io = value;
                        }
                }
 
                public IntPtr Handle {
                        get {
-                               return(socket.DangerousGetHandle ());
+                               return safe_handle.DangerousGetHandle ();
                        }
                }
 
@@ -431,7 +472,7 @@ namespace System.Net.Sockets
                // Wish:  support non-IP endpoints.
                public EndPoint LocalEndPoint {
                        get {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                
                                /*
@@ -445,7 +486,7 @@ namespace System.Net.Sockets
                                SocketAddress sa;
                                int error;
                                
-                               sa=LocalEndPoint_internal(socket, (int) address_family, out error);
+                               sa = LocalEndPoint_internal (safe_handle, (int) address_family, out error);
 
                                if (error != 0)
                                        throw new SocketException (error);
@@ -462,7 +503,7 @@ namespace System.Net.Sockets
 
                public int SendTimeout {
                        get {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
 
                                return (int)GetSocketOption(
@@ -470,7 +511,7 @@ namespace System.Net.Sockets
                                        SocketOptionName.SendTimeout);
                        }
                        set {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
 
                                if (value < -1)
@@ -492,7 +533,7 @@ namespace System.Net.Sockets
 
                public int ReceiveTimeout {
                        get {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
 
                                return (int)GetSocketOption(
@@ -500,7 +541,7 @@ namespace System.Net.Sockets
                                        SocketOptionName.ReceiveTimeout);
                        }
                        set {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
 
                                if (value < -1)
@@ -520,11 +561,11 @@ namespace System.Net.Sockets
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
                        
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
                        if (!IsBound)
                                throw new InvalidOperationException ("You must call the Bind method before performing this operation.");
-                       if (!islistening)
+                       if (!is_listening)
                                throw new InvalidOperationException ("You must call the Listen method before performing this operation.");
                        if (e.BufferList != null)
                                throw new ArgumentException ("Multiple buffers cannot be used with this method.");
@@ -565,15 +606,15 @@ namespace System.Net.Sockets
                }
 
                public Socket Accept() {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        int error = 0;
-                       var sock = Accept_internal(socket, out error, blocking);
+                       var sock = Accept_internal(safe_handle, out error, is_blocking);
 
                        if (error != 0) {
-                               if (closed)
-                                       error = SOCKET_CLOSED;
+                               if (is_closed)
+                                       error = SOCKET_CLOSED_CODE;
                                throw new SocketException(error);
                        }
 
@@ -587,23 +628,23 @@ namespace System.Net.Sockets
 
                internal void Accept (Socket acceptSocket)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
                        
                        int error = 0;
-                       var sock = Accept_internal (socket, out error, blocking);
+                       var sock = Accept_internal (safe_handle, out error, is_blocking);
                        
                        if (error != 0) {
-                               if (closed)
-                                       error = SOCKET_CLOSED;
+                               if (is_closed)
+                                       error = SOCKET_CLOSED_CODE;
                                throw new SocketException (error);
                        }
                        
                        acceptSocket.address_family = this.AddressFamily;
                        acceptSocket.socket_type = this.SocketType;
                        acceptSocket.protocol_type = this.ProtocolType;
-                       acceptSocket.socket = sock;
-                       acceptSocket.connected = true;
+                       acceptSocket.safe_handle = sock;
+                       acceptSocket.is_connected = true;
                        acceptSocket.seed_endpoint = this.seed_endpoint;
                        acceptSocket.Blocking = this.Blocking;
 
@@ -614,10 +655,10 @@ namespace System.Net.Sockets
 
                public IAsyncResult BeginAccept(AsyncCallback callback, object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
-                       if (!isbound || !islistening)
+                       if (!is_bound || !is_listening)
                                throw new InvalidOperationException ();
 
                        SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.Accept);
@@ -635,7 +676,7 @@ namespace System.Net.Sockets
                                                 AsyncCallback callback,
                                                 object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (receiveSize < 0)
@@ -661,14 +702,14 @@ namespace System.Net.Sockets
                                                 AsyncCallback callback,
                                                 object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (receiveSize < 0)
                                throw new ArgumentOutOfRangeException ("receiveSize", "receiveSize is less than zero");
 
                        if (acceptSocket != null) {
-                               if (acceptSocket.disposed && acceptSocket.closed)
+                               if (acceptSocket.is_disposed && acceptSocket.is_closed)
                                        throw new ObjectDisposedException (acceptSocket.GetType ().ToString ());
 
                                if (acceptSocket.IsBound)
@@ -703,7 +744,7 @@ namespace System.Net.Sockets
                                                  AsyncCallback callback,
                                                  object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (address == null)
@@ -715,7 +756,7 @@ namespace System.Net.Sockets
                        if (port <= 0 || port > 65535)
                                throw new ArgumentOutOfRangeException ("port", "Must be > 0 and < 65536");
 
-                       if (islistening)
+                       if (is_listening)
                                throw new InvalidOperationException ();
 
                        IPEndPoint iep = new IPEndPoint (address, port);
@@ -726,7 +767,7 @@ namespace System.Net.Sockets
                                                  AsyncCallback callback,
                                                  object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (host == null)
@@ -739,7 +780,7 @@ namespace System.Net.Sockets
                        if (port <= 0 || port > 65535)
                                throw new ArgumentOutOfRangeException ("port", "Must be > 0 and < 65536");
 
-                       if (islistening)
+                       if (is_listening)
                                throw new InvalidOperationException ();
 
                        return BeginConnect (Dns.GetHostAddresses (host), port, callback, state);
@@ -749,7 +790,7 @@ namespace System.Net.Sockets
                                                     AsyncCallback callback,
                                                     object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.Disconnect);
@@ -779,7 +820,7 @@ namespace System.Net.Sockets
                                                 AsyncCallback callback,
                                                 object state) {
 
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -825,7 +866,7 @@ namespace System.Net.Sockets
                                                  AsyncCallback callback,
                                                  object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffers == null)
@@ -864,7 +905,7 @@ namespace System.Net.Sockets
                                                     ref EndPoint remote_end,
                                                     AsyncCallback callback,
                                                     object state) {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -897,7 +938,7 @@ namespace System.Net.Sockets
                        SocketFlags socketFlags, ref EndPoint remoteEP,
                        AsyncCallback callback, object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -914,7 +955,7 @@ namespace System.Net.Sockets
                public IAsyncResult BeginSend (byte[] buffer, int offset, int size, SocketFlags socket_flags,
                                               AsyncCallback callback, object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -922,7 +963,7 @@ namespace System.Net.Sockets
 
                        CheckRange (buffer, offset, size);
 
-                       if (!connected)
+                       if (!is_connected)
                                throw new SocketException ((int)SocketError.NotConnected);
 
                        SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.Send);
@@ -947,7 +988,7 @@ namespace System.Net.Sockets
                                               AsyncCallback callback,
                                               object state)
                {
-                       if (!connected) {
+                       if (!is_connected) {
                                errorCode = SocketError.NotConnected;
                                throw new SocketException ((int)errorCode);
                        }
@@ -963,13 +1004,13 @@ namespace System.Net.Sockets
                                               AsyncCallback callback,
                                               object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffers == null)
                                throw new ArgumentNullException ("buffers");
 
-                       if (!connected)
+                       if (!is_connected)
                                throw new SocketException ((int)SocketError.NotConnected);
 
                        SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.SendGeneric);
@@ -992,7 +1033,7 @@ namespace System.Net.Sockets
                                               AsyncCallback callback,
                                               object state)
                {
-                       if (!connected) {
+                       if (!is_connected) {
                                errorCode = SocketError.NotConnected;
                                throw new SocketException ((int)errorCode);
                        }
@@ -1042,10 +1083,10 @@ namespace System.Net.Sockets
                                                   AsyncCallback callback,
                                                   object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
-                       if (!connected)
+                       if (!is_connected)
                                throw new NotSupportedException ();
 
                        if (!File.Exists (fileName))
@@ -1061,10 +1102,10 @@ namespace System.Net.Sockets
                                                   AsyncCallback callback,
                                                   object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
-                       if (!connected)
+                       if (!is_connected)
                                throw new NotSupportedException ();
 
                        if (!File.Exists (fileName))
@@ -1083,7 +1124,7 @@ namespace System.Net.Sockets
                                                EndPoint remote_end,
                                                AsyncCallback callback,
                                                object state) {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1128,7 +1169,7 @@ namespace System.Net.Sockets
                }
 
                public void Bind(EndPoint local_end) {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (local_end == null)
@@ -1136,11 +1177,11 @@ namespace System.Net.Sockets
                        
                        int error;
                        
-                       Bind_internal(socket, local_end.Serialize(), out error);
+                       Bind_internal (safe_handle, local_end.Serialize(), out error);
                        if (error != 0)
                                throw new SocketException (error);
                        if (error == 0)
-                               isbound = true;
+                               is_bound = true;
                        
                        seed_endpoint = local_end;
                }
@@ -1152,7 +1193,7 @@ namespace System.Net.Sockets
                
                public void Connect (IPAddress[] addresses, int port)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (addresses == null)
@@ -1162,7 +1203,7 @@ namespace System.Net.Sockets
                                this.AddressFamily != AddressFamily.InterNetworkV6)
                                throw new NotSupportedException ("This method is only valid for addresses in the InterNetwork or InterNetworkV6 families");
 
-                       if (islistening)
+                       if (is_listening)
                                throw new InvalidOperationException ();
 
                        /* FIXME: do non-blocking sockets Poll here? */
@@ -1171,10 +1212,10 @@ namespace System.Net.Sockets
                                IPEndPoint iep = new IPEndPoint (address, port);
                                SocketAddress serial = iep.Serialize ();
                                
-                               Connect_internal (socket, serial, out error);
+                               Connect_internal (safe_handle, serial, out error);
                                if (error == 0) {
-                                       connected = true;
-                                       isbound = true;
+                                       is_connected = true;
+                                       is_bound = true;
                                        seed_endpoint = iep;
                                        return;
                                } else if (error != (int)SocketError.InProgress &&
@@ -1182,12 +1223,12 @@ namespace System.Net.Sockets
                                        continue;
                                }
                                
-                               if (!blocking) {
+                               if (!is_blocking) {
                                        Poll (-1, SelectMode.SelectWrite);
                                        error = (int)GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error);
                                        if (error == 0) {
-                                               connected = true;
-                                               isbound = true;
+                                               is_connected = true;
+                                               is_bound = true;
                                                seed_endpoint = iep;
                                                return;
                                        }
@@ -1206,7 +1247,7 @@ namespace System.Net.Sockets
                public bool DisconnectAsync (SocketAsyncEventArgs e)
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        e.curSocket = this;
@@ -1236,12 +1277,12 @@ namespace System.Net.Sockets
                 */
                public void Disconnect (bool reuseSocket)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        int error = 0;
                        
-                       Disconnect_internal (socket, reuseSocket, out error);
+                       Disconnect_internal (safe_handle, reuseSocket, out error);
 
                        if (error != 0) {
                                if (error == 50) {
@@ -1252,7 +1293,7 @@ namespace System.Net.Sockets
                                }
                        }
 
-                       connected = false;
+                       is_connected = false;
                        
                        if (reuseSocket) {
                                /* Do managed housekeeping here... */
@@ -1265,13 +1306,13 @@ namespace System.Net.Sockets
                {
                        var si = new SocketInformation ();
                        si.Options =
-                               (islistening ? SocketInformationOptions.Listening : 0) |
-                               (connected ? SocketInformationOptions.Connected : 0) |
-                               (blocking ? 0 : SocketInformationOptions.NonBlocking) |
-                               (useoverlappedIO ? SocketInformationOptions.UseOnlyOverlappedIO : 0);
+                               (is_listening      ? SocketInformationOptions.Listening : 0) |
+                               (is_connected      ? SocketInformationOptions.Connected : 0) |
+                               (is_blocking       ? 0 : SocketInformationOptions.NonBlocking) |
+                               (use_overlapped_io ? SocketInformationOptions.UseOnlyOverlappedIO : 0);
 
-                       si.ProtocolInformation = Mono.DataConverter.Pack ("iiiil", (int)address_family, (int)socket_type, (int)protocol_type, isbound ? 1 : 0, (long)Handle);
-                       socket = null;
+                       si.ProtocolInformation = Mono.DataConverter.Pack ("iiiil", (int)address_family, (int)socket_type, (int)protocol_type, is_bound ? 1 : 0, (long)Handle);
+                       safe_handle = null;
 
                        return si;
                }
@@ -1293,7 +1334,7 @@ namespace System.Net.Sockets
 
                public Socket EndAccept (out byte[] buffer, out int bytesTransferred, IAsyncResult asyncResult)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (asyncResult == null)
@@ -1318,7 +1359,7 @@ namespace System.Net.Sockets
 
                public void EndConnect (IAsyncResult result)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (result == null)
@@ -1338,7 +1379,7 @@ namespace System.Net.Sockets
 
                public void EndDisconnect (IAsyncResult asyncResult)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (asyncResult == null)
@@ -1362,7 +1403,7 @@ namespace System.Net.Sockets
                                                  ref EndPoint endPoint,
                                                  out IPPacketInformation ipPacketInformation)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (asyncResult == null)
@@ -1382,7 +1423,7 @@ namespace System.Net.Sockets
 
                public void EndSendFile (IAsyncResult asyncResult)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (asyncResult == null)
@@ -1397,7 +1438,7 @@ namespace System.Net.Sockets
 
                public int EndSendTo (IAsyncResult result)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (result == null)
@@ -1437,7 +1478,7 @@ namespace System.Net.Sockets
 
                public void GetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, byte [] optionValue)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (optionValue == null)
@@ -1446,7 +1487,7 @@ namespace System.Net.Sockets
 
                        int error;
 
-                       GetSocketOption_arr_internal (socket, optionLevel, optionName, ref optionValue,
+                       GetSocketOption_arr_internal (safe_handle, optionLevel, optionName, ref optionValue,
                                out error);
                        if (error != 0)
                                throw new SocketException (error);
@@ -1454,13 +1495,13 @@ namespace System.Net.Sockets
 
                public byte [] GetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, int length)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        byte[] byte_val=new byte[length];
                        int error;
 
-                       GetSocketOption_arr_internal (socket, optionLevel, optionName, ref byte_val,
+                       GetSocketOption_arr_internal (safe_handle, optionLevel, optionName, ref byte_val,
                                out error);
                        if (error != 0)
                                throw new SocketException (error);
@@ -1492,11 +1533,11 @@ namespace System.Net.Sockets
 
                public int IOControl (int ioctl_code, byte [] in_value, byte [] out_value)
                {
-                       if (disposed)
+                       if (is_disposed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        int error;
-                       int result = WSAIoctl (socket, ioctl_code, in_value, out_value,
+                       int result = WSAIoctl (safe_handle, ioctl_code, in_value, out_value,
                                out error);
 
                        if (error != 0)
@@ -1530,24 +1571,24 @@ namespace System.Net.Sockets
 
                public void Listen (int backlog)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
-                       if (!isbound)
+                       if (!is_bound)
                                throw new SocketException ((int)SocketError.InvalidArgument);
 
                        int error;
-                       Listen_internal(socket, backlog, out error);
+                       Listen_internal(safe_handle, backlog, out error);
 
                        if (error != 0)
                                throw new SocketException (error);
 
-                       islistening = true;
+                       is_listening = true;
                }
 
                public bool Poll (int time_us, SelectMode mode)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (mode != SelectMode.SelectRead &&
@@ -1556,18 +1597,18 @@ namespace System.Net.Sockets
                                throw new NotSupportedException ("'mode' parameter is not valid.");
 
                        int error;
-                       bool result = Poll_internal (socket, mode, time_us, out error);
+                       bool result = Poll_internal (safe_handle, mode, time_us, out error);
                        if (error != 0)
                                throw new SocketException (error);
 
-                       if (mode == SelectMode.SelectWrite && result && !connected) {
-                               /* Update the connected state; for
+                       if (mode == SelectMode.SelectWrite && result && !is_connected) {
+                               /* Update the is_connected state; for
                                 * non-blocking Connect()s this is
                                 * when we can find out that the
                                 * connect succeeded.
                                 */
                                if ((int)GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Error) == 0) {
-                                       connected = true;
+                                       is_connected = true;
                                }
                        }
                        
@@ -1581,7 +1622,7 @@ namespace System.Net.Sockets
 
                public int Receive (byte [] buffer, SocketFlags flags)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1592,8 +1633,8 @@ namespace System.Net.Sockets
                        int ret = Receive_nochecks (buffer, 0, buffer.Length, flags, out error);
                        
                        if (error != SocketError.Success) {
-                               if (error == SocketError.WouldBlock && blocking) // This might happen when ReceiveTimeout is set
-                                       throw new SocketException ((int) error, timeout_exc_msg);
+                               if (error == SocketError.WouldBlock && is_blocking) // This might happen when ReceiveTimeout is set
+                                       throw new SocketException ((int) error, TIMEOUT_EXCEPTION_MSG);
                                throw new SocketException ((int) error);
                        }
 
@@ -1602,7 +1643,7 @@ namespace System.Net.Sockets
 
                public int Receive (byte [] buffer, int size, SocketFlags flags)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1615,8 +1656,8 @@ namespace System.Net.Sockets
                        int ret = Receive_nochecks (buffer, 0, size, flags, out error);
                        
                        if (error != SocketError.Success) {
-                               if (error == SocketError.WouldBlock && blocking) // This might happen when ReceiveTimeout is set
-                                       throw new SocketException ((int) error, timeout_exc_msg);
+                               if (error == SocketError.WouldBlock && is_blocking) // This might happen when ReceiveTimeout is set
+                                       throw new SocketException ((int) error, TIMEOUT_EXCEPTION_MSG);
                                throw new SocketException ((int) error);
                        }
 
@@ -1625,7 +1666,7 @@ namespace System.Net.Sockets
 
                public int Receive (byte [] buffer, int offset, int size, SocketFlags flags)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1638,8 +1679,8 @@ namespace System.Net.Sockets
                        int ret = Receive_nochecks (buffer, offset, size, flags, out error);
                        
                        if (error != SocketError.Success) {
-                               if (error == SocketError.WouldBlock && blocking) // This might happen when ReceiveTimeout is set
-                                       throw new SocketException ((int) error, timeout_exc_msg);
+                               if (error == SocketError.WouldBlock && is_blocking) // This might happen when ReceiveTimeout is set
+                                       throw new SocketException ((int) error, TIMEOUT_EXCEPTION_MSG);
                                throw new SocketException ((int) error);
                        }
 
@@ -1648,7 +1689,7 @@ namespace System.Net.Sockets
 
                public int Receive (byte [] buffer, int offset, int size, SocketFlags flags, out SocketError error)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1661,7 +1702,7 @@ namespace System.Net.Sockets
 
                public bool ReceiveFromAsync (SocketAsyncEventArgs e)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        // We do not support recv into multiple buffers yet
@@ -1690,7 +1731,7 @@ namespace System.Net.Sockets
 
                public int ReceiveFrom (byte [] buffer, ref EndPoint remoteEP)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1704,7 +1745,7 @@ namespace System.Net.Sockets
 
                public int ReceiveFrom (byte [] buffer, SocketFlags flags, ref EndPoint remoteEP)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1719,7 +1760,7 @@ namespace System.Net.Sockets
                public int ReceiveFrom (byte [] buffer, int size, SocketFlags flags,
                                        ref EndPoint remoteEP)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1762,7 +1803,7 @@ namespace System.Net.Sockets
                public int ReceiveFrom (byte [] buffer, int offset, int size, SocketFlags flags,
                                        ref EndPoint remoteEP)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1787,14 +1828,14 @@ namespace System.Net.Sockets
                                                   ref EndPoint remote_end, bool throwOnError, out int error)
                {
                        SocketAddress sockaddr = remote_end.Serialize();
-                       int cnt = RecvFrom_internal (socket, buf, offset, size, flags, ref sockaddr, out error);
+                       int cnt = RecvFrom_internal (safe_handle, buf, offset, size, flags, ref sockaddr, out error);
                        SocketError err = (SocketError) error;
                        if (err != 0) {
                                if (err != SocketError.WouldBlock && err != SocketError.InProgress)
-                                       connected = false;
-                               else if (err == SocketError.WouldBlock && blocking) { // This might happen when ReceiveTimeout is set
+                                       is_connected = false;
+                               else if (err == SocketError.WouldBlock && is_blocking) { // This might happen when ReceiveTimeout is set
                                        if (throwOnError)       
-                                               throw new SocketException ((int) SocketError.TimedOut, timeout_exc_msg);
+                                               throw new SocketException ((int) SocketError.TimedOut, TIMEOUT_EXCEPTION_MSG);
                                        error = (int) SocketError.TimedOut;
                                        return 0;
                                }
@@ -1804,8 +1845,8 @@ namespace System.Net.Sockets
                                return 0;
                        }
 
-                       connected = true;
-                       isbound = true;
+                       is_connected = true;
+                       is_bound = true;
 
                        // If sockaddr is null then we're a connection
                        // oriented protocol and should ignore the
@@ -1827,7 +1868,7 @@ namespace System.Net.Sockets
                public bool ReceiveMessageFromAsync (SocketAsyncEventArgs e)
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
                        
                        throw new NotImplementedException ();
@@ -1840,7 +1881,7 @@ namespace System.Net.Sockets
                                               ref EndPoint remoteEP,
                                               out IPPacketInformation ipPacketInformation)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -1862,7 +1903,7 @@ namespace System.Net.Sockets
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
                        
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
                        
                        throw new NotImplementedException ();
@@ -1870,7 +1911,7 @@ namespace System.Net.Sockets
 
                public int Send (byte [] buf)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buf == null)
@@ -1888,7 +1929,7 @@ namespace System.Net.Sockets
 
                public int Send (byte [] buf, SocketFlags flags)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buf == null)
@@ -1906,7 +1947,7 @@ namespace System.Net.Sockets
 
                public int Send (byte [] buf, int size, SocketFlags flags)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buf == null)
@@ -1926,7 +1967,7 @@ namespace System.Net.Sockets
 
                public int Send (byte [] buf, int offset, int size, SocketFlags flags)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buf == null)
@@ -1946,7 +1987,7 @@ namespace System.Net.Sockets
 
                public int Send (byte [] buf, int offset, int size, SocketFlags flags, out SocketError error)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buf == null)
@@ -1972,13 +2013,13 @@ namespace System.Net.Sockets
 
                public void SendFile (string fileName)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
-                       if (!connected)
+                       if (!is_connected)
                                throw new NotSupportedException ();
 
-                       if (!blocking)
+                       if (!is_blocking)
                                throw new InvalidOperationException ();
 
                        SendFile (fileName, null, null, 0);
@@ -1986,16 +2027,16 @@ namespace System.Net.Sockets
 
                public void SendFile (string fileName, byte[] preBuffer, byte[] postBuffer, TransmitFileOptions flags)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
-                       if (!connected)
+                       if (!is_connected)
                                throw new NotSupportedException ();
 
-                       if (!blocking)
+                       if (!is_blocking)
                                throw new InvalidOperationException ();
 
-                       if (!SendFile (socket, fileName, preBuffer, postBuffer, flags)) {
+                       if (!SendFile (safe_handle, fileName, preBuffer, postBuffer, flags)) {
                                SocketException exc = new SocketException ();
                                if (exc.ErrorCode == 2 || exc.ErrorCode == 3)
                                        throw new FileNotFoundException ();
@@ -2007,7 +2048,7 @@ namespace System.Net.Sockets
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
                        
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
                        if (e.BufferList != null)
                                throw new NotSupportedException ("Mono doesn't support using BufferList at this point.");
@@ -2034,7 +2075,7 @@ namespace System.Net.Sockets
                
                public int SendTo (byte [] buffer, EndPoint remote_end)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -2048,7 +2089,7 @@ namespace System.Net.Sockets
 
                public int SendTo (byte [] buffer, SocketFlags flags, EndPoint remote_end)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -2062,7 +2103,7 @@ namespace System.Net.Sockets
 
                public int SendTo (byte [] buffer, int size, SocketFlags flags, EndPoint remote_end)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -2104,7 +2145,7 @@ namespace System.Net.Sockets
                public int SendTo (byte [] buffer, int offset, int size, SocketFlags flags,
                                   EndPoint remote_end)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffer == null)
@@ -2125,18 +2166,18 @@ namespace System.Net.Sockets
 
                        int ret, error;
 
-                       ret = SendTo_internal (socket, buffer, offset, size, flags, sockaddr, out error);
+                       ret = SendTo_internal (safe_handle, buffer, offset, size, flags, sockaddr, out error);
 
                        SocketError err = (SocketError) error;
                        if (err != 0) {
                                if (err != SocketError.WouldBlock && err != SocketError.InProgress)
-                                       connected = false;
+                                       is_connected = false;
 
                                throw new SocketException (error);
                        }
 
-                       connected = true;
-                       isbound = true;
+                       is_connected = true;
+                       is_bound = true;
                        seed_endpoint = remote_end;
                        
                        return ret;
@@ -2144,7 +2185,7 @@ namespace System.Net.Sockets
 
                public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, byte [] optionValue)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        // I'd throw an ArgumentNullException, but this is what MS does.
@@ -2154,7 +2195,7 @@ namespace System.Net.Sockets
                        
                        int error;
 
-                       SetSocketOption_internal (socket, optionLevel, optionName, null,
+                       SetSocketOption_internal (safe_handle, optionLevel, optionName, null,
                                                 optionValue, 0, out error);
 
                        if (error != 0) {
@@ -2166,7 +2207,7 @@ namespace System.Net.Sockets
 
                public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        // NOTE: if a null is passed, the byte[] overload is used instead...
@@ -2179,17 +2220,17 @@ namespace System.Net.Sockets
                                LingerOption linger = optionValue as LingerOption;
                                if (linger == null)
                                        throw new ArgumentException ("A 'LingerOption' value must be specified.", "optionValue");
-                               SetSocketOption_internal (socket, optionLevel, optionName, linger, null, 0, out error);
+                               SetSocketOption_internal (safe_handle, optionLevel, optionName, linger, null, 0, out error);
                        } else if (optionLevel == SocketOptionLevel.IP && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) {
                                MulticastOption multicast = optionValue as MulticastOption;
                                if (multicast == null)
                                        throw new ArgumentException ("A 'MulticastOption' value must be specified.", "optionValue");
-                               SetSocketOption_internal (socket, optionLevel, optionName, multicast, null, 0, out error);
+                               SetSocketOption_internal (safe_handle, optionLevel, optionName, multicast, null, 0, out error);
                        } else if (optionLevel == SocketOptionLevel.IPv6 && (optionName == SocketOptionName.AddMembership || optionName == SocketOptionName.DropMembership)) {
                                IPv6MulticastOption multicast = optionValue as IPv6MulticastOption;
                                if (multicast == null)
                                        throw new ArgumentException ("A 'IPv6MulticastOption' value must be specified.", "optionValue");
-                               SetSocketOption_internal (socket, optionLevel, optionName, multicast, null, 0, out error);
+                               SetSocketOption_internal (safe_handle, optionLevel, optionName, multicast, null, 0, out error);
                        } else {
                                throw new ArgumentException ("Invalid value specified.", "optionValue");
                        }
@@ -2203,12 +2244,12 @@ namespace System.Net.Sockets
 
                public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, bool optionValue)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        int error;
                        int int_val = (optionValue) ? 1 : 0;
-                       SetSocketOption_internal (socket, optionLevel, optionName, null, null, int_val, out error);
+                       SetSocketOption_internal (safe_handle, optionLevel, optionName, null, null, int_val, out error);
                        if (error != 0) {
                                if (error == (int) SocketError.InvalidArgument)
                                        throw new ArgumentException ();
index 6a1e6c2b36a8ae8e89cab6535de3754ef4683a1a..d73401590fe37b6cc0f5ea96d71f23a517a49f6a 100644 (file)
@@ -83,7 +83,7 @@ namespace System.Net.Sockets
                {
                        this.Sock = sock;
                        if (sock != null) {
-                               this.blocking = sock.blocking;
+                               this.blocking = sock.is_blocking;
                                this.handle = sock.Handle;
                        } else {
                                this.blocking = true;
@@ -140,7 +140,7 @@ namespace System.Net.Sockets
                public SocketAsyncResult (Socket sock, object state, AsyncCallback callback, SocketOperation operation)
                {
                        this.Sock = sock;
-                       this.blocking = sock.blocking;
+                       this.blocking = sock.is_blocking;
                        this.handle = sock.Handle;
                        this.state = state;
                        this.callback = callback;
@@ -153,12 +153,12 @@ namespace System.Net.Sockets
                public void CheckIfThrowDelayedException ()
                {
                        if (delayedException != null) {
-                               Sock.connected = false;
+                               Sock.is_connected = false;
                                throw delayedException;
                        }
 
                        if (error != 0) {
-                               Sock.connected = false;
+                               Sock.is_connected = false;
                                throw new SocketException (error);
                        }
                }
@@ -184,7 +184,7 @@ namespace System.Net.Sockets
 
                public void Complete ()
                {
-                       if (operation != SocketOperation.Receive && Sock.disposed)
+                       if (operation != SocketOperation.Receive && Sock.is_disposed)
                                delayedException = new ObjectDisposedException (Sock.GetType ().ToString ());
 
                        IsCompleted = true;
@@ -213,7 +213,7 @@ namespace System.Net.Sockets
                                                queue.Dequeue (); // remove ourselves
                                        if (queue.Count > 0) {
                                                worker = (SocketAsyncWorker) queue.Peek ();
-                                               if (!Sock.disposed) {
+                                               if (!Sock.is_disposed) {
                                                        sac = SocketAsyncWorker.Dispatcher;
                                                } else {
                                                        CompleteAllOnDispose (queue);
index e58b0463058946367655ad33f2703450ff12854e..939f957e31b524cfd29d6999347984c49b758a9c 100644 (file)
@@ -211,8 +211,8 @@ namespace System.Net.Sockets
                                        if (is_mconnect)
                                                result = mconnect;
                                        result.Sock.seed_endpoint = ep;
-                                       result.Sock.connected = true;
-                                       result.Sock.isbound = true;
+                                       result.Sock.is_connected = true;
+                                       result.Sock.is_bound = true;
                                        result.Sock.connect_in_progress = false;
                                        result.error = 0;
                                        result.Complete ();
@@ -318,7 +318,7 @@ namespace System.Net.Sockets
                        // Actual send() done in the runtime
                        if (result.error == 0) {
                                UpdateSendValues (result.Total);
-                               if (result.Sock.disposed) {
+                               if (result.Sock.is_disposed) {
                                        result.Complete ();
                                        return;
                                }
index 7a4649e607bc2d37fda004ca31e15df1f5ddb2ce..dffacfc8767b40082a8b14c10d40528934a2c3ef 100644 (file)
@@ -58,36 +58,26 @@ namespace System.Net.Sockets {
                        public IntPtr buf;
                }
 
-               internal Queue readQ = new Queue (2);
-               internal Queue writeQ = new Queue (2);
-
-               /*
-                *      These two fields are looked up by name by the runtime, don't change
-                *  their name without also updating the runtime code.
-                */
-               private static int ipv4Supported = -1, ipv6Supported = -1;
-               int linger_timeout;
-
                static Socket ()
                {
-                       // initialize ipv4Supported and ipv6Supported
+                       // initialize ipv4_supported and ipv6_supported
                        CheckProtocolSupport ();
                }
 
                internal static void CheckProtocolSupport ()
                {
-                       if(ipv4Supported == -1) {
+                       if(ipv4_supported == -1) {
                                try {
                                        Socket tmp = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                                        tmp.Close();
 
-                                       ipv4Supported = 1;
+                                       ipv4_supported = 1;
                                } catch {
-                                       ipv4Supported = 0;
+                                       ipv4_supported = 0;
                                }
                        }
 
-                       if (ipv6Supported == -1) {
+                       if (ipv6_supported == -1) {
                                // We need to put a try/catch around ConfigurationManager methods as will always throw an exception 
                                // when run in a mono embedded application.  This occurs as embedded applications do not have a setup
                                // for application config.  The exception is not thrown when called from a normal .NET application. 
@@ -103,28 +93,28 @@ namespace System.Net.Sockets {
                                        SettingsSection config;
                                        config = (SettingsSection) System.Configuration.ConfigurationManager.GetSection ("system.net/settings");
                                        if (config != null)
-                                               ipv6Supported = config.Ipv6.Enabled ? -1 : 0;
+                                               ipv6_supported = config.Ipv6.Enabled ? -1 : 0;
                                } catch {
-                                       ipv6Supported = -1;
+                                       ipv6_supported = -1;
                                }
 #else
                                try {
                                        NetConfig config = System.Configuration.ConfigurationSettings.GetConfig("system.net/settings") as NetConfig;
                                        if (config != null)
-                                               ipv6Supported = config.ipv6Enabled ? -1 : 0;
+                                               ipv6_supported = config.ipv6Enabled ? -1 : 0;
                                } catch {
-                                       ipv6Supported = -1;
+                                       ipv6_supported = -1;
                                }
 #endif
 #endif
-                               if (ipv6Supported != 0) {
+                               if (ipv6_supported != 0) {
                                        try {
                                                Socket tmp = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
                                                tmp.Close();
 
-                                               ipv6Supported = 1;
+                                               ipv6_supported = 1;
                                        } catch {
-                                               ipv6Supported = 0;
+                                               ipv6_supported = 0;
                                        }
                                }
                        }
@@ -133,7 +123,7 @@ namespace System.Net.Sockets {
                public static bool SupportsIPv4 {
                        get {
                                CheckProtocolSupport();
-                               return ipv4Supported == 1;
+                               return ipv4_supported == 1;
                        }
                }
 
@@ -141,14 +131,14 @@ namespace System.Net.Sockets {
                public static bool SupportsIPv6 {
                        get {
                                CheckProtocolSupport();
-                               return ipv6Supported == 1;
+                               return ipv6_supported == 1;
                        }
                }
 #if NET_2_1
                public static bool OSSupportsIPv4 {
                        get {
                                CheckProtocolSupport();
-                               return ipv4Supported == 1;
+                               return ipv4_supported == 1;
                        }
                }
 #endif
@@ -156,7 +146,7 @@ namespace System.Net.Sockets {
                public static bool OSSupportsIPv6 {
                        get {
                                CheckProtocolSupport();
-                               return ipv6Supported == 1;
+                               return ipv6_supported == 1;
                        }
                }
 #else
@@ -173,31 +163,6 @@ namespace System.Net.Sockets {
                }
 #endif
 
-               /* the field "socket" is looked up by name by the runtime */
-               private SafeSocketHandle socket;
-               private AddressFamily address_family;
-               private SocketType socket_type;
-               private ProtocolType protocol_type;
-               internal bool blocking=true;
-               internal bool isbound;
-               /* When true, the socket was connected at the time of
-                * the last IO operation
-                */
-               internal bool connected;
-               /* true if we called Close_internal */
-               private bool closed;
-               internal bool disposed;
-               internal bool connect_in_progress;
-
-               /*
-                * This EndPoint is used when creating new endpoints. Because
-                * there are many types of EndPoints possible,
-                * seed_endpoint.Create(addr) is used for creating new ones.
-                * As such, this value is set on Bind, SentTo, ReceiveFrom,
-                * Connect, etc.
-                */
-               internal EndPoint seed_endpoint = null;
-
                // Creates a new system socket, returning the handle
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private extern IntPtr Socket_internal(AddressFamily family,
@@ -242,7 +207,7 @@ namespace System.Net.Sockets {
                        int error;
                        
                        var handle = Socket_internal (addressFamily, socketType, protocolType, out error);
-                       socket = new SafeSocketHandle (handle, true);
+                       safe_handle = new SafeSocketHandle (handle, true);
 
                        if (error != 0)
                                throw new SocketException (error);
@@ -288,26 +253,26 @@ namespace System.Net.Sockets {
 
                public bool Blocking {
                        get {
-                               return(blocking);
+                               return is_blocking;
                        }
                        set {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
 
                                int error;
                                
-                               Blocking_internal (socket, value, out error);
+                               Blocking_internal (safe_handle, value, out error);
 
                                if (error != 0)
                                        throw new SocketException (error);
                                
-                               blocking=value;
+                               is_blocking = value;
                        }
                }
 
                public bool Connected {
-                       get { return connected; }
-                       internal set { connected = value; }
+                       get { return is_connected; }
+                       internal set { is_connected = value; }
                }
 
                public ProtocolType ProtocolType {
@@ -316,7 +281,7 @@ namespace System.Net.Sockets {
 
                public bool NoDelay {
                        get {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
 
                                ThrowIfUpd ();
@@ -327,7 +292,7 @@ namespace System.Net.Sockets {
                        }
 
                        set {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
 
                                ThrowIfUpd ();
@@ -340,13 +305,13 @@ namespace System.Net.Sockets {
 
                public int ReceiveBufferSize {
                        get {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
                                return((int)GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer));
                        }
                        set {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
                                if (value < 0) {
@@ -359,13 +324,13 @@ namespace System.Net.Sockets {
 
                public int SendBufferSize {
                        get {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
                                return((int)GetSocketOption (SocketOptionLevel.Socket, SocketOptionName.SendBuffer));
                        }
                        set {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
                                if (value < 0) {
@@ -380,7 +345,7 @@ namespace System.Net.Sockets {
 
                public short Ttl {
                        get {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
                                
@@ -397,7 +362,7 @@ namespace System.Net.Sockets {
                                return(ttl_val);
                        }
                        set {
-                               if (disposed && closed) {
+                               if (is_disposed && is_closed) {
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                }
                                if (value < 0) {
@@ -432,7 +397,7 @@ namespace System.Net.Sockets {
 
                public EndPoint RemoteEndPoint {
                        get {
-                               if (disposed && closed)
+                               if (is_disposed && is_closed)
                                        throw new ObjectDisposedException (GetType ().ToString ());
                                
                                /*
@@ -440,12 +405,12 @@ namespace System.Net.Sockets {
                                 * etc has not yet been called. MS returns null
                                 * in this case.
                                 */
-                               if (!connected || seed_endpoint == null)
+                               if (!is_connected || seed_endpoint == null)
                                        return null;
                                SocketAddress sa;
                                int error;
                                
-                               sa=RemoteEndPoint_internal(socket, (int) address_family, out error);
+                               sa = RemoteEndPoint_internal (safe_handle, (int) address_family, out error);
 
                                if (error != 0)
                                        throw new SocketException (error);
@@ -456,7 +421,7 @@ namespace System.Net.Sockets {
 
                void Linger (IntPtr handle)
                {
-                       if (!connected || linger_timeout <= 0)
+                       if (!is_connected || linger_timeout <= 0)
                                return;
 
                        // We don't want to receive any more data
@@ -487,21 +452,21 @@ namespace System.Net.Sockets {
 
                protected virtual void Dispose (bool disposing)
                {
-                       if (disposed)
+                       if (is_disposed)
                                return;
 
-                       disposed = true;
-                       bool was_connected = connected;
-                       connected = false;
+                       is_disposed = true;
+                       bool was_connected = is_connected;
+                       is_connected = false;
                        
-                       if (socket != null) {
-                               closed = true;
+                       if (safe_handle != null) {
+                               is_closed = true;
                                IntPtr x = Handle;
 
                                if (was_connected)
                                        Linger (x);
 
-                               socket.Dispose ();
+                               safe_handle.Dispose ();
                        }
                }
 
@@ -549,7 +514,7 @@ namespace System.Net.Sockets {
                {
                        SocketAddress serial = null;
 
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (remoteEP == null)
@@ -560,34 +525,34 @@ namespace System.Net.Sockets {
                                if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any))
                                        throw new SocketException ((int) SocketError.AddressNotAvailable);
 
-                       if (islistening)
+                       if (is_listening)
                                throw new InvalidOperationException ();
                        serial = remoteEP.Serialize ();
 
                        int error = 0;
 
-                       Connect_internal (socket, serial, out error);
+                       Connect_internal (safe_handle, serial, out error);
 
                        if (error == 0 || error == 10035)
                                seed_endpoint = remoteEP; // Keep the ep around for non-blocking sockets
 
                        if (error != 0) {
-                               if (closed)
-                                       error = SOCKET_CLOSED;
+                               if (is_closed)
+                                       error = SOCKET_CLOSED_CODE;
                                throw new SocketException (error);
                        }
 
                        if (socket_type == SocketType.Dgram && ep != null && (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any)))
-                               connected = false;
+                               is_connected = false;
                        else
-                               connected = true;
-                       isbound = true;
+                               is_connected = true;
+                       is_bound = true;
                }
 
                public bool ReceiveAsync (SocketAsyncEventArgs e)
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        // LAME SPEC: the ArgumentException is never thrown, instead an NRE is
@@ -624,7 +589,7 @@ namespace System.Net.Sockets {
                public bool SendAsync (SocketAsyncEventArgs e)
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
                        if (e.Buffer == null && e.BufferList == null)
                                throw new NullReferenceException ("Either e.Buffer or e.BufferList must be valid buffers.");
@@ -694,13 +659,13 @@ namespace System.Net.Sockets {
                internal int Receive_nochecks (byte [] buf, int offset, int size, SocketFlags flags, out SocketError error)
                {
                        int nativeError;
-                       int ret = Receive_internal (socket, buf, offset, size, flags, out nativeError);
+                       int ret = Receive_internal (safe_handle, buf, offset, size, flags, out nativeError);
                        error = (SocketError) nativeError;
                        if (error != SocketError.Success && error != SocketError.WouldBlock && error != SocketError.InProgress) {
-                               connected = false;
-                               isbound = false;
+                               is_connected = false;
+                               is_bound = false;
                        } else {
-                               connected = true;
+                               is_connected = true;
                        }
                        
                        return ret;
@@ -755,15 +720,15 @@ namespace System.Net.Sockets {
 
                        int nativeError;
 
-                       int ret = Send_internal (socket, buf, offset, size, flags, out nativeError);
+                       int ret = Send_internal (safe_handle, buf, offset, size, flags, out nativeError);
 
                        error = (SocketError)nativeError;
 
                        if (error != SocketError.Success && error != SocketError.WouldBlock && error != SocketError.InProgress) {
-                               connected = false;
-                               isbound = false;
+                               is_connected = false;
+                               is_bound = false;
                        } else {
-                               connected = true;
+                               is_connected = true;
                        }
 
                        return ret;
@@ -771,13 +736,13 @@ namespace System.Net.Sockets {
 
                public object GetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        object obj_val;
                        int error;
 
-                       GetSocketOption_obj_internal (socket, optionLevel, optionName, out obj_val,
+                       GetSocketOption_obj_internal (safe_handle, optionLevel, optionName, out obj_val,
                                out error);
                        if (error != 0)
                                throw new SocketException (error);
@@ -811,15 +776,15 @@ namespace System.Net.Sockets {
 
                public void Shutdown (SocketShutdown how)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
-                       if (!connected)
+                       if (!is_connected)
                                throw new SocketException (10057); // Not connected
 
                        int error;
                        
-                       Shutdown_internal (socket, how, out error);
+                       Shutdown_internal (safe_handle, how, out error);
                        if (error != 0)
                                throw new SocketException (error);
                }
@@ -847,12 +812,12 @@ namespace System.Net.Sockets {
 
                public void SetSocketOption (SocketOptionLevel optionLevel, SocketOptionName optionName, int optionValue)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        int error;
 
-                       SetSocketOption_internal (socket, optionLevel, optionName, null,
+                       SetSocketOption_internal (safe_handle, optionLevel, optionName, null,
                                                 null, optionValue, out error);
 
                        if (error != 0)
@@ -870,7 +835,7 @@ namespace System.Net.Sockets {
                public
                IAsyncResult BeginConnect(EndPoint end_point, AsyncCallback callback, object state)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (end_point == null)
@@ -894,38 +859,38 @@ namespace System.Net.Sockets {
                                // Calling connect() again will reset the connection attempt and cause
                                // an error. Better to just close the socket and move on.
                                connect_in_progress = false;
-                               socket.Dispose ();
+                               safe_handle.Dispose ();
                                var handle = Socket_internal (address_family, socket_type, protocol_type, out error);
-                               socket = new SafeSocketHandle (handle, true);
+                               safe_handle = new SafeSocketHandle (handle, true);
                                if (error != 0)
                                        throw new SocketException (error);
                        }
-                       bool blk = blocking;
+                       bool blk = is_blocking;
                        if (blk)
                                Blocking = false;
                        SocketAddress serial = end_point.Serialize ();
-                       Connect_internal (socket, serial, out error);
+                       Connect_internal (safe_handle, serial, out error);
                        if (blk)
                                Blocking = true;
                        if (error == 0) {
                                // succeeded synch
-                               connected = true;
-                               isbound = true;
+                               is_connected = true;
+                               is_bound = true;
                                req.Complete (true);
                                return req;
                        }
 
                        if (error != (int) SocketError.InProgress && error != (int) SocketError.WouldBlock) {
                                // error synch
-                               connected = false;
-                               isbound = false;
+                               is_connected = false;
+                               is_bound = false;
                                req.Complete (new SocketException (error), true);
                                return req;
                        }
 
                        // continue asynch
-                       connected = false;
-                       isbound = false;
+                       is_connected = false;
+                       is_bound = false;
                        connect_in_progress = true;
                        socket_pool_queue (SocketAsyncWorker.Dispatcher, req);
                        return req;
@@ -935,7 +900,7 @@ namespace System.Net.Sockets {
                IAsyncResult BeginConnect (IPAddress[] addresses, int port, AsyncCallback callback, object state)
 
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (addresses == null)
@@ -950,13 +915,13 @@ namespace System.Net.Sockets {
 
                        if (port <= 0 || port > 65535)
                                throw new ArgumentOutOfRangeException ("port", "Must be > 0 and < 65536");
-                       if (islistening)
+                       if (is_listening)
                                throw new InvalidOperationException ();
 
                        SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.Connect);
                        req.Addresses = addresses;
                        req.Port = port;
-                       connected = false;
+                       is_connected = false;
                        return BeginMConnect (req);
                }
 
@@ -1042,9 +1007,9 @@ namespace System.Net.Sockets {
                public bool ConnectAsync (SocketAsyncEventArgs e)
                {
                        // NO check is made whether e != null in MS.NET (NRE is thrown in such case)
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
-                       if (islistening)
+                       if (is_listening)
                                throw new InvalidOperationException ("You may not perform this operation after calling the Listen method.");
                        if (e.RemoteEndPoint == null)
                                throw new ArgumentNullException ("remoteEP");
@@ -1094,7 +1059,7 @@ namespace System.Net.Sockets {
                public
                int Receive (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (buffers == null ||
@@ -1128,7 +1093,7 @@ namespace System.Net.Sockets {
                        }
 
                        try {
-                               ret = Receive_internal (socket, bufarray,
+                               ret = Receive_internal (safe_handle, bufarray,
                                                        socketFlags,
                                                        out nativeError);
                        } finally {
@@ -1186,7 +1151,7 @@ namespace System.Net.Sockets {
                public
                int Send (IList<ArraySegment<byte>> buffers, SocketFlags socketFlags, out SocketError errorCode)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
                        if (buffers == null)
                                throw new ArgumentNullException ("buffers");
@@ -1211,7 +1176,7 @@ namespace System.Net.Sockets {
                        }
 
                        try {
-                               ret = Send_internal (socket, bufarray, socketFlags, out nativeError);
+                               ret = Send_internal (safe_handle, bufarray, socketFlags, out nativeError);
                        } finally {
                                for(int i = 0; i < numsegments; i++) {
                                        if (gch[i].IsAllocated) {
@@ -1235,7 +1200,7 @@ namespace System.Net.Sockets {
                        int bytesReceived = EndReceive (result, out error);
                        if (error != SocketError.Success) {
                                if (error != SocketError.WouldBlock && error != SocketError.InProgress)
-                                       connected = false;
+                                       is_connected = false;
                                throw new SocketException ((int)error);
                        }
                        return bytesReceived;
@@ -1244,7 +1209,7 @@ namespace System.Net.Sockets {
                public
                int EndReceive (IAsyncResult asyncResult, out SocketError errorCode)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (asyncResult == null)
@@ -1275,7 +1240,7 @@ namespace System.Net.Sockets {
                        int bytesSent = EndSend (result, out error);
                        if (error != SocketError.Success) {
                                if (error != SocketError.WouldBlock && error != SocketError.InProgress)
-                                       connected = false;
+                                       is_connected = false;
                                throw new SocketException ((int)error);
                        }
                        return bytesSent;
@@ -1284,7 +1249,7 @@ namespace System.Net.Sockets {
                public
                int EndSend (IAsyncResult asyncResult, out SocketError errorCode)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
                        if (asyncResult == null)
                                throw new ArgumentNullException ("asyncResult");
@@ -1311,7 +1276,7 @@ namespace System.Net.Sockets {
                public
                int EndReceiveFrom(IAsyncResult result, ref EndPoint end_point)
                {
-                       if (disposed && closed)
+                       if (is_disposed && is_closed)
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        if (result == null)
index a3c2ac0c336bc91921b783d5c028ac31a28182cf..3a0b10e64ad174241c06c1a7f98c4cf70465e0dc 100644 (file)
@@ -633,8 +633,8 @@ static gint32 get_family_hint(void)
                MonoVTable *vtable;
 
                socket_class = mono_class_from_name (get_socket_assembly (), "System.Net.Sockets", "Socket");
-               ipv4_field = mono_class_get_field_from_name (socket_class, "ipv4Supported");
-               ipv6_field = mono_class_get_field_from_name (socket_class, "ipv6Supported");
+               ipv4_field = mono_class_get_field_from_name (socket_class, "ipv4_supported");
+               ipv6_field = mono_class_get_field_from_name (socket_class, "ipv6_supported");
                vtable = mono_class_vtable (mono_domain_get (), socket_class);
                g_assert (vtable);
                mono_runtime_class_init (vtable);
@@ -1573,7 +1573,7 @@ static SOCKET Socket_to_SOCKET(MonoObject *sockobj)
        MonoSafeHandle *safe_handle;
        MonoClassField *field;
        
-       field = mono_class_get_field_from_name (sockobj->vtable->klass, "socket");
+       field = mono_class_get_field_from_name (sockobj->vtable->klass, "safe_handle");
        safe_handle = ((MonoSafeHandle*) (*(gpointer *)(((char *)sockobj)+field->offset)));
 
        if (safe_handle == NULL)