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 { } }
/// <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 { } }