コード例 #1
0
        void Conc_Errored(object sender, TCPErroredArgs e)
        {
            this.textBox_Log.AddString("无法连接:" + e.Error.ToString());

            EnableControls(true);

            if (_conc != null)
            {
                _conc.ClearEvents();
                _conc = null;
            }
            if (_acc != null)
            {
                _acc.ClearEvents();
                _acc = null;
            }
        }
コード例 #2
0
        private void button_Connect_Click(object sender, EventArgs e)
        {
            int port;

            if (!int.TryParse(this.textBox_RemotePort.Text, out port) || port <= 0)
            {
                MessageBox.Show("请输入有效端口");
                return;
            }



            _conc           = new TcpSocketConnector();
            _conc.Accepted += new EventHandler <TCPConnectedArgs>(Con_Accepted);
            _conc.Errored  += new EventHandler <TCPErroredArgs>(Conc_Errored);

            _conc.Connect(this.textBox_RemoteAddress.Text, int.Parse(this.textBox_RemotePort.Text));
            EnableControls(false);
        }