protected void runEchoService ( ServerSocket serverSocket ) { if ( isRunning ( serverSocket ) ) { echoService = newExecutorService ( ) ; echoService . submit ( ( ) -> { try { while ( isRunning ( serverSocket ) ) { Socket echoClient = serverSocket . accept ( ) ; getLogger ( ) . info ( ( ) -> String . format ( "EchoClient connected from [%s]" , echoClient . getRemoteSocketAddress ( ) ) ) ; echoService . submit ( ( ) -> { sendResponse ( echoClient , receiveMessage ( echoClient ) ) ; close ( echoClient ) ; } ) ; } } catch ( IOException cause ) { if ( isRunning ( serverSocket ) ) { getLogger ( ) . warning ( ( ) -> String . format ( "An IO error occurred while listening for EchoClients:%n%s" , ThrowableUtils . getStackTrace ( cause ) ) ) ; } } } ) ; getLogger ( ) . info ( ( ) -> String . format ( "EchoServer running on port [%d]" , getPort ( ) ) ) ; } }
Starts the echo service .