[Mono-bugs] [Bug 70827][Nor] New - Reading from an Empty Non-Blocking socket will (Incorrectly) close the Socket

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 27 Dec 2004 13:42:52 -0500 (EST)

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 scott@imeem.com.


--- shadow/70827	2004-12-27 13:42:52.000000000 -0500
+++ shadow/70827.tmp.29598	2004-12-27 13:42:52.000000000 -0500
@@ -0,0 +1,58 @@
+Bug#: 70827
+Product: Mono: Class Libraries
+Version: 1.1
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: scott@imeem.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Reading from an Empty Non-Blocking socket will (Incorrectly) close the Socket
+Please fill in this template when reporting a bug, unless you know what you are doing.
+Description of Problem:
+Reading from a non-Blocking socket when no data is availabled causes the socket to close. 
+This is different from the .Net behaviour.
+Steps to reproduce the problem:
+IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(""),80); 
+// pick a destination which doesn't send data back
+Socket sock = new (Socket(endPoint,AddressFamily, SocketType.Stream,
+if(sock.Connected) {
+    try {
+        sock.Blocking = false;
+        byte[] test = new byte[8];
+        sock.Receive(test);
+    }
+    catch (Exception e)
+    {
+        Console.WriteLine("Connected = " + sock.Connected);
+    }
+Actual Results:
+Mono will output "Connected = false", the socket is now useless
+Expected Results:
+.Net will output "Connected = true", the socket may still be used for reading and writing
+How often does this happen? 
+Additional Information:
+It looks like Receive_internal checks for an error code, if this is set it closes the connection 
+without actually checking what the error code is, there are many error codes which are more 
+informative and do not indicate a failure in the underlying tcp socket. The type of code should be 
+checked and the socket should only be closed if the error indicates the underlying connection is