Page 259 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 259

}



                            public  void  connectsocket(){
                            try{
                                 socket  =  new  Socket("192.168.0.11", 8001);
                                 if(socket.isConnected())  alertText("Socket  Connect");

                            }catch  (Exception e){
                                 e.printStackTrace();
                                 //  alertText("연결중");
                            }
                       }



                            public  void  alertText(String  msg)  {
                            final  String  text  =  msg;


                            handler.post(new  Runnable() {

                                 @Override
                                 public  void run()  {
                                       textView.setText("");
                                       textView.append(text  +  "\n");
                                 }

                            });
                       }
                 }


                 class  CloseThread  extends  Thread  {                                //  소켓  끊기



                       public  void  run()  {
                            close();
                       }



                            public  void  close()  {
                            try {
                                 oos.flush();
                                 socket.close();
                                 if  (socket.isClosed())  alertText("Socket  Disconnect");

                            }catch  (Exception e)  {




                                                         -  252  -
   254   255   256   257   258   259   260   261   262   263   264