我试图在ISDN端使用BRI接口在ISDN网络中使用C#代码接收广播消息。接收广播消息
我看到在使用Comm View工具的一些端口上发送到广播IP地址(239.255.255.255)的数据包。
但是,当我尝试收听此IP地址时,它说该地址不在有效的上下文中。
但是,当我发送广播消息到255.255.255.255的端口上,我可以用下面的代码收到这些消息..
什么能与此IP地址的问题 - 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 + "\"");
}
}
有发送到广播ip地址(239.255.255.255),我可以在Commview工具包看,但不能从代码收到他们...
任何人可以帮我请?
请多关照,
普拉萨德Kancharla。
嗨.. 感谢您的答复..我解决它从以下链接 http://stackoverflow.com/questions/2271183/udp-packet-capturing-in-c 谢谢, 普拉萨德 – Prasad 2010-03-29 10:41:02