[Mono-bugs] [Bug 45959][Cri] Changed - UDP Sockets: Multicast and Broadcast Datagrams are not received

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Thu, 10 Jul 2003 13:03:11 -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 giuseppe.greco@agamura.com.

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

--- shadow/45959	Thu Jul 10 11:46:46 2003
+++ shadow/45959.tmp.5225	Thu Jul 10 13:03:11 2003
@@ -225,6 +225,53 @@
 
 Gius_.
 
 ------- Additional Comments From dick@ximian.com  2003-07-10 11:46 -------
 Its a race condition in your code, which means that whether the async
 thread gets the new or old version of "data" is random.
+
+------- Additional Comments From giuseppe.greco@agamura.com  2003-07-10 13:03 -------
+Well, now I've modified my code as following:
+
+private void Listen()
+{
+  byte[] data = null;
+  EndPoint endPoint = null;
+  int recv = 0;
+                                                                     
+                              
+  while (!isDisposed) {
+    if (socket.Poll(PollTimeOut, SelectMode.SelectRead)) {
+      data = new byte[socket.Available];
+      endPoint = (EndPoint) localEndPoint;
+                                                                     
+                              
+      recv = socket.ReceiveFrom(
+        data,
+        0,
+        data.Length,
+        SocketFlags.None,
+        ref endPoint);
+                                                                     
+                              
+      if (recv > 0) {
+        Datagram datagram = NetConverter.ToDatagram(data, 0);
+        ReceiveEventArgs e = new ReceiveEventArgs(datagram);
+                                                                     
+                              
+        if (Receive != null) {
+          Receive(this, e);
+        }
+      }
+    }
+  }
+}
+
+In the code above, Poll() is not executed until the datagram
+is completely received by ReceiveFrom()... but I'm still
+not able to receive Multicast and Broadcast datagrams.
+
+Gius_.
+
+                                                                     
+                              
+