private void SendToAll(string mes) { MyClient m = new MyClient(); Socket[] asoc = m.GetListAll(); byte[] bmsg = new byte[1024]; bmsg = Encoding.Unicode.GetBytes(mes); foreach (Socket s in asoc) { s.Send(bmsg); } }
private void GetAllClientList() { MyClient m = new MyClient(); Socket[] msoc = m.GetListAll(); ListAllClinet.Clear(); allclinet.Clear(); int index = 0; foreach (Socket s in msoc) { IPEndPoint Ip = s.RemoteEndPoint as IPEndPoint; ListAllClinet.Add(Ip.Address + ":" + Ip.Port, index); allclinet.Add(Ip.Address + ":" + Ip.Port); index++; } int a = rnd.Next(2500, 5000); int b = rnd.Next(2300, 4700); int c = rnd.Next(20, 30); string rands = "ran:" + a + ":" + b + ":" + c + ":" + (index); SendToSpecificClient(rands, allclinet[index - 1]); //Console.WriteLine(ListAllClinet[index-1]); }