public ConnObj getconn(String ip, int port) { ConnObj[] cobs = new ConnObj[Connlist.Count]; Connlist.CopyTo(0, cobs, 0, cobs.Length); foreach (ConnObj cb in cobs) { if (cb != null) { try { if (cb.Soc.RemoteEndPoint != null) { IPEndPoint clientipe = (IPEndPoint)cb.Soc.RemoteEndPoint; if ((clientipe.Address.ToString() + ":" + clientipe.Port) == (ip + ":" + port)) { return(cb); } } } catch { } } } return(null); }
public void removeconn(Socket soc) { ConnObj[] cobs = new ConnObj[Connlist.Count]; Connlist.CopyTo(0, cobs, 0, cobs.Length); for (int i = 0; i < count; i++) { if (cobs[i] != null) { if (cobs[i].Soc.Equals(soc)) { try { cobs[i].Soc.Dispose(); } catch { } try { Connlist.Remove(cobs[i]); } catch { } return; } } } }
public void removeconn(Socket soc) { IPEndPoint clientipe = (IPEndPoint)soc.RemoteEndPoint; string key = clientipe.Address.ToString() + ":" + clientipe.Port; //这里通过IP和PORT获取对象 if (Connlist.ContainsKey(key)) { Connlist.Remove(key); } }
public ConnObj getconn(String ip, int port) { string key = ip + ":" + port; //这里通过IP和PORT获取对象 if (Connlist.ContainsKey(key)) { return(Connlist[key]); } else { return(null); } }
public ConnObj getconn(Socket soc) { IPEndPoint clientipe = (IPEndPoint)soc.RemoteEndPoint; string key = clientipe.Address.ToString() + ":" + clientipe.Port; //这里通过IP和PORT获取对象 if (Connlist.ContainsKey(key)) { return(Connlist[key]); } else { return(null); } }
// int count = 0; public void setconn(ConnObj cb) { IPEndPoint clientipe = (IPEndPoint)cb.Soc.RemoteEndPoint; llbb11: string key = clientipe.Address.ToString() + ":" + clientipe.Port; Connlist.Add(key, cb); if (Connlist.ContainsKey(key)) { return; } else { goto llbb11; } }
public ConnObj getconn(Socket soc) { ConnObj[] cobs = new ConnObj[Connlist.Count]; Connlist.CopyTo(0, cobs, 0, cobs.Length); foreach (ConnObj cb in cobs) { try { if (cb != null) { if (cb.Soc.Equals(soc)) { return(cb); } } } catch { } } return(null); }