Page 988 - 3-2
P. 988

Thread thread = new Thread(r);
                    thread.start();
                }


                private static void log(String msg) {
                    System.out.println("["+(new Date()) + "] " + msg);
                }


            }




            class ServerRunable implements Runnable{
                    //UUID for SPP
                final UUID uuid = new UUID("0000110100001000800000805F9B34FB", false);
                final String CONNECTION_URL_FOR_SPP = "btspp://localhost:"
                                    + uuid +";name=SPP Server";


                private StreamConnectionNotifier mStreamConnectionNotifier = null;
                private StreamConnection mStreamConnection = null;
                private int count = 0;




                    @Override
                    public void run() {


                    try {
                            mStreamConnectionNotifier = (StreamConnectionNotifier) Connector
                                                            .open(CONNECTION_URL_FOR_SPP);
                            log("Opened connection successful.");
                    } catch (IOException e) {
                            log("Could not open connection: " + e.getMessage());
                            return;
                    }
                    log("Server is now running.");
                    while(true){
                            log("wait for client requests...");
                            try {
                                    mStreamConnection = mStreamConnectionNotifier.acceptAndOpen();
                            } catch (IOException e1) {
                                    log("Could not open connection: " + e1.getMessage() );
                            }
                            count++;
                            log(" 현재 접속 중인 클라이언트 수: " + count);
                            new Receiver(mStreamConnection).start();
                    }


                                                         - 988 -
   983   984   985   986   987   988   989   990   991   992   993