private void SendMsgToOne(System.Net.IPAddress ip, int port, ClassMsg msg)//发送消息给一个用户 { try { System.IO.MemoryStream stream = new ClassSerializers().SerializerBinary(msg); QQClass.UDPSocket udp = new QQClass.UDPSocket(); udp.Send(ip, port, stream.ToArray()); } catch { } }
private void SendMsgToAll(ClassMsg msg)//发送消息给所有用户 { try { foreach (System.Windows.Forms.ListViewItem item in this.LV_SysUser.Items) { System.Net.IPAddress ip = System.Net.IPAddress.Parse(item.SubItems[1].Text); int port = Convert.ToInt32(item.SubItems[2].Text); System.IO.MemoryStream stream = new ClassSerializers().SerializerBinary(msg); QQClass.UDPSocket udp = new QQClass.UDPSocket(); udp.Send(ip, port, stream.ToArray()); } } catch { } }