Пример #1
0
        /**********************************
        *
        *        Form Load Event
        *
        **********************************/
        private void Form1_Load(object sender, EventArgs e)
        {
            ERR_RESULT result = new ERR_RESULT();

            try
            {
                m_SocketClass.CreateSocket();                                      //서버 소켓 생성
                m_server = m_SocketClass.Server;                                   //생성된 소켓
                m_server.BeginAccept(new AsyncCallback(AcceptCallBack), m_server); //접속할 클라이언트를 비동기적으로 받을 준비
                Thread newThread = new Thread(() => CheckConnect());
                newThread.IsBackground = true;
                newThread.Start();
            }
            catch (_MainException err)
            {
                result = ErrProcess.SetErrResult(err);
                m_err.SetErrCall(result);
            }
            catch (Exception err)
            {
                result = ErrProcess.SetErrResult(err);
                m_err.SetErrCall(result);
            }
        }
Пример #2
0
        /*********************************
         *
         *    Socket Connect Button Event
         *
         **********************************/
        private void btn_connect_Click(object sender, EventArgs e)
        {
            ERR_RESULT result = new ERR_RESULT();

            try
            {
                m_ip   = tx_Ip.Text;
                m_port = Int32.Parse(tx_Port.Text);

                m_clientClass.ConnectServer(m_ip, m_port);                                     //사용자가 입력한 ip와 port번호로 접속
                m_client = m_clientClass.Client;                                               //생성 소켓 객체
                m_remote = m_clientClass.RemoteEp;                                             //생성 소켓 주소정보
                m_client.BeginConnect(m_remote, new AsyncCallback(ConnectCallBack), m_client); //서버와 연결 준비
                Thread newThread = new Thread(() => CheckConnect());
                newThread.IsBackground = true;
                newThread.Start();

                if (m_client.Connected)
                {
                    lb_status.Text = "Connected to Server!"; //연결 상태 메세지 변경
                }
                else
                {
                    lb_status.Text = "Server Waiting....";
                }
            }
            catch (_MainException err)
            {
                result = ErrProcess.SetErrResult(err);
                m_err.SetErrCall(result);
            }
            catch (Exception err)
            {
                result = ErrProcess.SetErrResult(err);
                m_err.SetErrCall(result);
            }
        }
Пример #3
0
        /***********************************
        *
        *        Form Load Event
        *
        * *********************************/
        private void Form1_Load(object sender, EventArgs e)
        {
            ERR_RESULT result = new ERR_RESULT();

            try
            {
                m_SocketClass.CreateSocket();                                      //서버 소켓 생성
                m_server = m_SocketClass.Server;                                   //생성된 소켓
                m_server.BeginAccept(new AsyncCallback(AcceptCallBack), m_server); //접속할 클라이언트를 비동기적으로 받을 준비
                pictureBox1.BackColor = Color.Red;
                m_task = Task.Factory.StartNew(() => CheckFunc(), m_token.Token);  //Event Check Thread 시작
            }
            catch (_MainException err)
            {
                result = ErrProcess.SetErrResult(err);
                m_err.SetErrCall(result);
            }
            catch (Exception err)
            {
                result = ErrProcess.SetErrResult(err);
                m_err.SetErrCall(result);
            }
        }