日期:2014-05-17 浏览次数:20693 次
static Dictionary<string, Socket> ClientList = new Dictionary<string, Socket>();
var client= ar.AsyncState as Socket;
var ipport = client.RemoteEndPoint.ToString();
ClientList.Add(ipport, client);
var ip=1;
var port=2;
var new=ClientList.select("key not like " +ip+"%");
new.add(ip+":"+port,client);
Client=new;
private void InsertNewIP(string sIp, string sPort, Socket newSocket)
{
string sFindKey = ClientList.Keys.Where(x => x.Substring(0, x.IndexOf(':')) == sIp).SingleOrDefault();
if (sFindKey == null)
{
ClientList.Add(sIp + ":" + sPort, newSocket);
}
else
{
ClientList.Remove(sFindKey);
ClientList.Add(sIp + ":" + sPort, newSocket);
}
}