Author: dick
Date: 2005-10-11 09:20:59 -0400 (Tue, 11 Oct 2005)
New Revision: 51565

Modified:
   trunk/mcs/class/System/System.Net.Sockets/ChangeLog
   trunk/mcs/class/System/System.Net.Sockets/Socket.cs
Log:

2005-10-11  Dick Porter  <[EMAIL PROTECTED]>

        * Socket.cs: Don't call connect(2) twice for non-blocking sockets,
        it breaks on macos (and probably other bsd-based stacks too,) use
        poll() and getsockopt() to check if it worked.




Modified: trunk/mcs/class/System/System.Net.Sockets/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net.Sockets/ChangeLog 2005-10-11 13:09:21 UTC 
(rev 51564)
+++ trunk/mcs/class/System/System.Net.Sockets/ChangeLog 2005-10-11 13:20:59 UTC 
(rev 51565)
@@ -1,3 +1,9 @@
+2005-10-11  Dick Porter  <[EMAIL PROTECTED]>
+
+       * Socket.cs: Don't call connect(2) twice for non-blocking sockets,
+       it breaks on macos (and probably other bsd-based stacks too,) use
+       poll() and getsockopt() to check if it worked.
+
 2005-09-27 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
        * Socket.cs: add checks for 'disposed' all over. Fixes bug #76249.

Modified: trunk/mcs/class/System/System.Net.Sockets/Socket.cs
===================================================================
--- trunk/mcs/class/System/System.Net.Sockets/Socket.cs 2005-10-11 13:09:21 UTC 
(rev 51564)
+++ trunk/mcs/class/System/System.Net.Sockets/Socket.cs 2005-10-11 13:20:59 UTC 
(rev 51565)
@@ -283,8 +283,19 @@
                        public void Connect ()
                        {
                                try {
-                                       result.Sock.Connect (result.EndPoint);
-                                       result.Sock.connected = true;
+                                       if (!result.Sock.Blocking) {
+                                               result.Sock.Poll (-1, 
SelectMode.SelectWrite);
+                                               int success = 
(int)result.Sock.GetSocketOption (SocketOptionLevel.Socket, 
SocketOptionName.Error);
+                                               if (success == 0) {
+                                                       result.Sock.connected = 
true;
+                                               } else {
+                                                       result.Complete (new 
SocketException (success));
+                                                       return;
+                                               }
+                                       } else {
+                                               result.Sock.Connect 
(result.EndPoint);
+                                               result.Sock.connected = true;
+                                       }
                                } catch (Exception e) {
                                        result.Complete (e);
                                        return;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to