[Mono-bugs] [Bug 75351][Maj] New - UDP Socket does not receive
broadcast UDP packets
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Jun 22 09:26:21 EDT 2005
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 will at memefeeder.com.
http://bugzilla.ximian.com/show_bug.cgi?id=75351
--- shadow/75351 2005-06-22 09:26:21.000000000 -0400
+++ shadow/75351.tmp.16780 2005-06-22 09:26:21.000000000 -0400
@@ -0,0 +1,113 @@
+Bug#: 75351
+Product: Mono: Class Libraries
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: Gentoo 2005.0 running mono 1.1.7
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: System
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: will at memefeeder.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: UDP Socket does not receive broadcast UDP packets
+
+Description of Problem:
+
+A Socket object bound to a specific UDP port does not receive UDP broadcast
+packets sent to that port
+
+
+Steps to reproduce the problem:
+1. Run attached code
+
+
+Actual Results:
+
+Call to Socket.Receive() never returns.
+
+
+Expected Results:
+
+Socket.Receive() should return, having received the packet.
+
+
+How often does this happen?
+
+Every time.
+
+
+Additional Information:
+
+Socket receives packet as expected when running under Microsoft .NET
+runtime (1.0 and 1.1)
+
+
+/* --- BEGIN CODE --- */
+using System;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading;
+
+namespace UdpBroadcastTest
+{
+ class Class1
+ {
+ [STAThread]
+ static void Main(string[] args)
+ {
+ Thread lThread = new Thread(new ThreadStart(RunListener));
+ lThread.Start();
+
+ Thread sThread = new Thread(new ThreadStart(RunSender));
+ sThread.Start();
+ }
+
+ static void RunListener()
+ {
+ Console.WriteLine("Listener running...");
+ Socket mySock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
+ProtocolType.Udp);
+
+ IPEndPoint myEP = new
+IPEndPoint(Dns.Resolve(Dns.GetHostName()).AddressList[0], 9999);
+ mySock.Bind(myEP);
+
+ while(true)
+ {
+ byte[] buf = new byte[1024];
+ Console.WriteLine("Listener listening...");
+ int numRecvd = mySock.Receive(buf);
+
+ Console.WriteLine("Listener received packet, size "+numRecvd);
+ }
+ }
+
+ static void RunSender()
+ {
+ Socket mySock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
+ProtocolType.Udp);
+ mySock.SetSocketOption(SocketOptionLevel.Socket,
+SocketOptionName.Broadcast, 1);
+
+ //IPEndPoint myEP = new
+IPEndPoint(Dns.Resolve(Dns.GetHostName()).AddressList[0], 9999);
+ IPEndPoint myEP = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 9999);
+
+ byte[] buf = new byte[1024];
+
+ while(true)
+ {
+ Thread.Sleep(2000);
+
+ Console.WriteLine("Sender sending");
+ mySock.SendTo(buf, 63, SocketFlags.None, myEP);
+ }
+ }
+ }
+}
+/* --- END CODE --- */
More information about the mono-bugs
mailing list