示例#1
0
        /// <summary>
        /// 开启监听
        /// </summary>
        private void StartLisen()
        {
            try
            {
                while (true)
                {
                    string   s = kz.H_Recv();
                    string[] r = s.Split(',');
                    if (r[0] == "1")
                    {
                        outport = Convert.ToInt32(r[1]);
                        TcpClient  tc1        = new TcpClient(inip, inport);
                        TcpClient  tc2        = new TcpClient(outip, outport);
                        ConnectMap connectMap = new ConnectMap {
                            InClient = tc1, OutClient = tc2, Outip = outip1
                        };
                        Dis(() =>
                        {
                            connectMaps.Add(connectMap);
                            SetIndex();
                        });

                        PortHelper.Lianjie(connectMap);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Logger("客户端开启监听出错 " + ex.Message);
                kz.Dispose();
                tc.Close();
            }
        }