我想在我自己的局域网中进行UDP广播,共有13台机器,希望每个程序发送的信息其他12台都能收到,本身也能收到自己发出的信息。本人使用msdn上的代码不好用,总是在加入广播组的时候抛出异常说参数不正确,我现在做个小应用程序,将发送及接收全部放在程序中,是否可行??我把源码附上希望各位大哥帮忙看看,谢谢了!!private int port = 11000;监听接收端
private void StartListen()
{
bool istrue = false; UdpClient UdpListen = new UdpClient();
IPEndPoint myip = new IPEndPoint(IPAddress.Parse("224.168.100.2"),this.port); try
{
UdpListen.JoinMulticastGroup(IPAddress.Parse("224.168.100.2"));  //错误处,提示参数无效
UdpListen.Connect(myip);

while(!istrue)
{
this.listBox1.Items.Add("the BroadCast waiting...");
byte [] Recbyte =UdpListen.Receive(ref myip); 
this.textBoxRece.Text = System.Text.Encoding.ASCII.GetString(Recbyte,0,Recbyte.Length);
}
UdpListen.Close();
}
catch(Exception myExc)
{
MessageBox.Show(this,myExc.Message,"Error",MessageBoxButtons.OK);
}
}发送端 //发送信息
UdpClient SendUdp = new UdpClient();
IPEndPoint SendIP = new IPEndPoint(IPAddress.Parse("224.168.100.2"),this.port);//

byte[] sendbyt = System.Text.Encoding.ASCII.GetBytes(this.textBox_Send.Text); SendUdp.Send(sendbyt,sendbyt.Length); SendUdp.Close();