C# ip hash算法实现ip分流

      private void button42_Click(object sender, EventArgs e)
{
Dictionary<int, string> proxyIpNodes = new Dictionary<int, string>();
proxyIpNodes.Add(, "XINNIU_IP_PROXY:XINNIU_IP_PROXY_POOL5");
proxyIpNodes.Add(, "XINNIU_IP_PROXY:XINNIU_IP_PROXY_POOL3"); var ip = textBox5.Text;
var iphashcode = ip.GetHashCode(); if (iphashcode < ) iphashcode = -iphashcode;
int serverListSize = proxyIpNodes.Count;
int serverPos = iphashcode % serverListSize; textBox6.AppendText(proxyIpNodes[serverPos+]+ System.Environment.NewLine);
}
上一篇:Facade模式


下一篇:phpstorm,webstorm取消自动保存并标识修改的文件为星星标记