Quantcast

No UDP broadcast messages received

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

No UDP broadcast messages received

sharkal
This post has NOT been accepted by the mailing list yet.
Hi,
i want to listen to a specific UDP port and receiving all messages, which are sent on that port.
I only receive messages, which are sent directly to my IP address, but do not receive messages, which are sent broadcast.
My openSuse is receiving the messages for sure, since i checked it with wireshark,  turned off the firewall and also can receive the messages, if i do the same with python.
In Windows i can receive also the broadcast messages.
Any idea, how to deal with it?

The socket is configured something like this:

Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
clientSocket.ReceiveBufferSize = 2 * 1024 * 1024;
clientSocket.Bind(localEndPoint);
clientSocket.BeginReceiveFrom(receivebuffer, 0, receivebuffer.Length,
                    SocketFlags.None, ref localEndPoint, OnReceiveCallback, clientSocket);

clientSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);
clientSocket.EnableBroadcast = true;
remoteIpAddress = IPAddress.Broadcast;
remoteEndPoint = new IPEndPoint(remoteIpAddress, ADMIN_PORT);
clientSocket.SendTo(sendbuffer, sendbuffer.Length, SocketFlags.None, remoteEndPoint);


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: No UDP broadcast messages received

sharkal
This post has NOT been accepted by the mailing list yet.
I could fix the problem by my own now.
The thing is, the remoteIpAddress has to be the broadcast address of the subnet.
And the localEndPoint which i used to bind the socket has to be set to  "IPAddress.Any"
A possible way to get the subnet mask under linux with mono  i found on this page:
http://stackoverflow.com/questions/8119414/how-to-query-the-subnet-masks-using-mono-on-linux

for the broadcast address in the subnet of the ip, i also found somewhere in google an implementation, which generates the address with the ip address and the subnetmask.

Loading...