public void run ( ) { try { mServer = new ServerSocket ( mPort , VIEW_SERVER_MAX_CONNECTIONS , InetAddress . getLocalHost ( ) ) ; } catch ( Exception e ) { Log . w ( LOG_TAG , "Starting ServerSocket error: " , e ) ; } while ( mServer != null && Thread . currentThread ( ) == mThread ) { // Any uncaught exception will crash the system process try { Socket client = mServer . accept ( ) ; if ( mThreadPool != null ) { mThreadPool . submit ( new ViewServerWorker ( client ) ) ; } else { try { client . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } catch ( Exception e ) { Log . w ( LOG_TAG , "Connection error: " , e ) ; } } }
Main server loop .