Пример #1
0
 private void SendMsgToOne(IPAddress ip, int port, ClassMsg msg)
 {
     try
     {
         MemoryStream stream = new ClassSerializers().SerializeBinary(msg);
         UDPSocket udp = new UDPSocket();
         udp.Send(ip, port, stream.ToArray());
     }
     catch
     { }
 }
Пример #2
0
 /// <summary>
 /// 发送信息给所有用户
 /// </summary>
 /// <param name="msg"></param>
 private void SendMsgToAll(ClassMsg msg)
 {
     try
     {
         foreach (ListViewItem item in this.LV_SysUser.Items)
         {
             IPAddress ip = IPAddress.Parse(item.SubItems[1].Text);
             int port = Convert.ToInt32(item.SubItems[2].Text);
             MemoryStream stream = new ClassSerializers().SerializeBinary(msg);
             UDPSocket udp = new UDPSocket();
             udp.Send(ip, port, stream.ToArray());
         }
     }
     catch
     { }
 }