private static void SendMsg()
{
//主机名称
string hostName = Dns.GetHostName();
//要发送的人的名称
string sendTo = "zhangdongyan";
//端口
int port = 2425;
//存放发送消息的字节数组
byte[] msgContent = null;
string msg = "1:" + DateTime.Now.ToFileTime() + ":" + sendTo + ":" + hostName + ":" + "32:" + "这个是测试的!";
string msg1 = "1:1273050382:Administrator:"+Dns.GetHostName()+":zhangdongyan:192.168.0.66:fsdfsdfsf";
msgContent = Encoding.Default.GetBytes(msg);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
sock.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Broadcast, 1);
IPEndPoint iep1 = new IPEndPoint(IPAddress.Any, 2425);//255.255.255.255
IPEndPoint iep2 = new IPEndPoint(IPAddress.Parse("192.168.0.133"),2425);
//sock.SendTo(msgContent,iep1);
sock.SendTo(msgContent, iep2);
sock.Close();
}