コード例 #1
0
        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);
        }
コード例 #2
0
        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;
                    }
                }
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        public ConnObj getconn(String ip, int port)
        {
            string key = ip + ":" + port;

            //这里通过IP和PORT获取对象
            if (Connlist.ContainsKey(key))
            {
                return(Connlist[key]);
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        // 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;
            }
        }
コード例 #7
0
 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);
 }