Code example for BluetoothServerSocket

Methods: accept, close

0
			BluetoothSocket socket = null;
 
	        while (true) { 
				log_v("AcceptThread: run() loop"); 
	            try { 
	                socket = mBTServerSocket.accept();
					log_v("AcceptThread: run() accepted"); 
	            } catch (IOException e) {
					log_w("AcceptThread: run() accept() caused IOException"); 
	                break; 
	            } 
				log_v("AcceptThread: run() outside of try"); 
	             
	            // If a connection was accepted 
	            if (socket != null) {
	                manageConnectedServerSocket(socket);
	            } 
				log_v("AcceptThread: run() after socket check"); 
 
                try { 
    				log_v("AcceptThread: run() closing server socket"); 
					mBTServerSocket.close();
    				log_v("AcceptThread: run() closed server socket"); 
				} catch (IOException e) {
					log_w( "IOException on closing Bluetooth server socket" ); 
				} 
                break;