Please do not reply to this email- if you want to comment on the bug, go to the URL shown below and enter your comments there.
Changed by [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=79878 --- shadow/79878 2006-11-09 11:43:48.000000000 -0500 +++ shadow/79878.tmp.9637 2006-11-09 11:43:48.000000000 -0500 @@ -0,0 +1,84 @@ +Bug#: 79878 +Product: Mono: Class Libraries +Version: 1.1 +OS: +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Major +Component: System +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: BeginConnect/EndConnect for Socket does not work correctly on connection error + +Description of Problem: +When trying to connect a Socket instance asynchronously and the attempt +fails for whatever reason, the connected bit is set true when it should be +false. + +Steps to reproduce the problem: +Run attached test case (tcp socket 1234 on localhost should be closed so +the attempt to connect fails). + +Actual Results: +socket.Connected is true when Callback is invoked, even though the +connection failed, as the test case shows. + +Expected Results: +When the callback registered with BeginConnect is invoked, Connected should +be false if some error happened. Output for test case should thus be +socket connected False, op completed True +Hit key to end: + +How often does this happen? +Failure is 100% reproduceable on mono 1.1.something and current svn and +work as expected on .Net. + +Additional Information: +Comments to code snippets from mcs/class/System/System.Net.Socket/Socket.cs: +(line 288-299) + public void Connect () + { + try { + 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; + } +[...] +On instantiation of a Socket, connected is false. Connect calls Poll, which +the snippet from below is from. I don't believe connected should be set +true here, because the result of Poll_internal doesn't say whether the +socket is connected or not that is reflected by GetSocketOption it seems +from the code above. +(line 1344-1358) + int error; + bool result = Poll_internal (socket, mode, time_us, out error); + if (error != 0) + throw new SocketException (error); + + if (result == true) { + /* Update the connected state; for + * non-blocking Connect()s this is + * when we can find out that the + * connect succeeded. + */ + connected = true; + } + + return result; +[...] + +So from the point of solving my problem, removing connected = true; from +Poll works (I tested it). If other relies on Poll setting connected I guess +Poll could call GetSocketOption like Connect does. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
