[Mono-bugs] [Bug 45633][Nor] New - UdpClient.Receive will only return the first 512 bytes under certain circumstances

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Mon, 30 Jun 2003 07:01:24 -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 lmaloney@bigpond.net.au.

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

--- shadow/45633	Mon Jun 30 07:01:24 2003
+++ shadow/45633.tmp.15096	Mon Jun 30 07:01:24 2003
@@ -0,0 +1,45 @@
+Bug#: 45633
+Product: Mono/Class Libraries
+Version: unspecified
+OS: other
+OS Details: Linux 2.4.17 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lmaloney@bigpond.net.au               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: UdpClient.Receive will only return the first 512 bytes under certain circumstances
+
+Description of Problem:
+The current implementation of UdpClient.Receive (as of June 30 2003) will
+only return the first 512 bytes of a packet if there is no data ready when
+the function begins.
+
+It could possibly be fixed by calling Socket.Poll before allocating the
+buffer so the correct size is known.
+
+I can supply more information if necessary.
+
+Current code:
+
+int available = socket.Available;
+if (available < 512)
+    available = 512;
+recBuffer = new byte [available];
+
+EndPoint endPoint = new IPEndPoint (IPAddress.Any, 0);
+int dataRead = socket.ReceiveFrom (recBuffer, ref endPoint);
+
+Suggested code:
+
+EndPoint endPoint = new IPEndPoint (IPAddress.Any, 0);
+socket.Poll (-1, SelectMode.SelectRead);
+int available = socket.Available;
+recBuffer = new byte [available];
+socket.ReceiveFrom (recBuffer, ref endPoint);