[Mono-bugs] [Bug 74475][Nor] New - BeginWrite returns to the callback before all bytes are written

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 7 Apr 2005 02:59:48 -0400 (EDT)


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 harningt@gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=74475

--- shadow/74475	2005-04-07 02:59:48.000000000 -0400
+++ shadow/74475.tmp.4886	2005-04-07 02:59:48.000000000 -0400
@@ -0,0 +1,56 @@
+Bug#: 74475
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: AMD64 + Gentoo + NPTL
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: harningt@gmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: BeginWrite returns to the callback before all bytes are written
+
+Description of Problem:
+  When using BeginSend on a socket to do Async IO, it may "return" early
+before writing all the bytes to the socket, causing EndWrite to return a
+lower value than the length is.
+According to MS documentation, the BeginSend function will only stop
+sending on error/disconnection or completion.
+This limitation kills the queuing of BeginSend where the data must be in
+order and complete (basically all cases of TCP communications...
+missing/out-of-order data is bad).
+To send out the data, you must repeatedly BeginSend
+
+Steps to reproduce the problem:
+1. Call BeginWrite on a socket connected via TCP [a large data amount would
+more likely cause this issue]
+2.  Call EndWrite in either the callback or to block the call until
+completion when not using callbacks.
+
+Actual Results:
+  It may return a value less than the total number of bytes that should
+have been written (actually writes only that amount).
+
+Expected Results:
+  It should have returned a value equal to the length of the data sent on
+it, thus causing the entire buffer to have been sent at once (well, if
+length and offset are set such that the entire buffer is used).
+
+How often does this happen? 
+  More often with larger data amounts.
+
+Additional Information:
+  The Microsoft Documentation and implementation does not allow for this to
+be the case.  BeginWrite will always write the full data out, not returning
+early (which I find quite retarded.. the OS/socket implementation should
+keep putting out the data until its done unless there is some major issue
+at hand like socket closing or errors).  With async IO, the whole purpose
+is to not block on IO and let the IO complete fully... With .Net's
+BeginWrite, queuing up the writes are a useful concept so data's ready to
+be shoved down the line.