Hi,

I'm trying to receive broadcast messages using C# code in an ISDN network with BRI interface at my end.

I see the packets sent to the broadcast ip address (239.255.255.255) on some ports using Comm View tool.

But when I try to listen to this IP address, it says the address is not in a valid context.

But when I send broadcast messages to 255.255.255.255 on a port, I can receive those messages with the below code..

What could be the problem with this ip address - 239.255.255.255 ?

The code I use to listen to broadcast messages is..

UdpClient udp = new UdpClient();
IPEndPoint receiveEndPoint = new IPEndPoint(IPAddress.Any, 8013);
// If I use IPAddress.Parse("239.255.255.255") to listen to, it says "the address is not in a valid // context."
udp.Client.Bind(receiveEndPoint);
udp.BeginReceive(_Callback, udp);

static private void _Callback(IAsyncResult iar)
{
            try
            {
                UdpClient client = (UdpClient)iar.AsyncState;

                client.BeginReceive(_Callback, client);

                IPEndPoint ipRemote = new IPEndPoint(IPAddress.Any, 8013);

                byte[] rgb = client.EndReceive(iar, ref ipRemote);

                Console.WriteLine("Received {0} bytes: \"{1}\"",
                rgb.Length.ToString(), Encoding.UTF8.GetString(rgb));
            }
            catch (ObjectDisposedException)
            {
                Console.WriteLine("closing listening socket");
            }
            catch (Exception exc)
            {
                Console.WriteLine("Listening socket error: \"" +
                exc.Message + "\"");
            }
  }

There are packets sent to the broadcast ipaddress (239.255.255.255) which I can see in Commview tool, but can't receive them from the code...


Can anybody help me out please?


Thanking you in advance,
Prasad Kancharla.

Recommended Answers

It was my understanding (and I did a little searching that didn't disagree) packets sent to 239.255.255.255 should be available to anyone with a 239.x.x.x address.

Does your computer have a 239.x.x.x address?

Are you listening to the right port?

Jump to Post

All 4 Replies

It was my understanding (and I did a little searching that didn't disagree) packets sent to 239.255.255.255 should be available to anyone with a 239.x.x.x address.

Does your computer have a 239.x.x.x address?

Are you listening to the right port?

Hi Murtan,

Thanks for your reply,

My IP address is in a different series - 192.168.2.6, but I'm connecting to an ISDN network on BRI interface using 1841 router.. their network broadcast ip address is 239.255.255.255. and if somebody in their network sends a broadcast message, it reaches my system on a port 8013 ( I can see it in Commview tool for e.g. I see that there is a broadcast packet sent from an IP 192.168.X.X to 239.255.255.255 on a port 8013 )..

How do I listen to those messages from C#?

Thanks again for your time..

Regards,
Prasad

If you're running the commview tool on your same computer, I guess the packets are on your network (though I wouldn't have expected them to be).

Is there any way to associate a 239.x.x.x address with your computer (as well as your current ip address) so that you are 'entitled' to the messages?

If not, I vaguely recall a mode for a connection or card that allowed it to 'see' network packets that were not addressed to it. (If commview is seeing the 239 broadcasts I think that's how it works), but I'm not aware of how to put it in that mode.

I remembered the name 'promiscuous mode' for this type of connection. Looking it up as a definition I find:
http://en.wikipedia.org/wiki/Promiscuous_mode

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.