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

// This  is a  blocking  call  and will  only return  on  a

                                       // successful  connection  or an  exception

                                       socket = mmServerSocket.accept();


                                 } catch (IOException  e)  {

                                       Log.e(TAG,  "Socket  Type: " + mSocketType +  "accept()  failed",  e);

                                       break;

                                 }

                                 //  If  a connection  was  accepted


                                 if  (socket  != null) {

                                       synchronized (BluetoothTestService.this) {

                                            switch  (mState) {

                                                 case  STATE_LISTEN:

                                                 case  STATE_CONNECTING:


                                                       // Situation  normal. Start the  connected  thread.

                                                       connected(socket,  socket.getRemoteDevice(),

                                                                   mSocketType);    // 연결이  되었을  경우..

                                                       break;

                                                 case  STATE_NONE:


                                                 case  STATE_CONNECTED:

                                       // Either  not  ready  or  already  connected.  Terminate  new  socket.

                                                       try  {

                                                            socket.close();

                                                       }  catch  (IOException e)  {


                                                            Log.e(TAG,  "Could not close  unwanted  socket",  e);

                                                       }

                                                       break;




                                                         -  560  -
   562   563   564   565   566   567   568   569   570   571   572