//按组发送 public static void SocketSendByGroup(int groupId, Package pkg) { m_tryToRemoveSocketIdBuffer.Clear(); foreach (int key in socketPool.Keys) { try { BaseSocket s = socketPool[key]; //组Id匹配 if (groupId == s.GetGroupId()) { var sendBytes = PackageHelper.GetNetworkSendBuffer(pkg);; if (s.SocketSend(sendBytes, 0, sendBytes.Length) != SOCKET_CODE.SUCCESS) { m_tryToRemoveSocketIdBuffer.Add(key); } } } catch { m_tryToRemoveSocketIdBuffer.Add(key); } } foreach (int id in m_tryToRemoveSocketIdBuffer) { socketPool[id].SocketClose(); socketPool.Remove(id); } m_tryToRemoveSocketIdBuffer.Clear(); }