private void closeOutgoingSockets ( ) throws ClientException { SocketOperator op = new SocketOperator ( ) { public void operate ( SocketBox sb ) throws Exception { if ( ( ( ManagedSocketBox ) sb ) . isReusable ( ) ) { Socket s = sb . getSocket ( ) ; if ( s != null ) { // write the closing Eblock and close the socket EBlockImageDCWriter . close ( new DataOutputStream ( s . getOutputStream ( ) ) ) ; } } } } ; try { socketPool . applyToAll ( op ) ; } catch ( IOException e ) { // ignore - sometimes server might close the socket } catch ( Exception e ) { ClientException ce = new ClientException ( ClientException . SOCKET_OP_FAILED ) ; ce . setRootCause ( e ) ; throw ce ; } }
All sockets opened when this server was active should send a special EBlock header before closing .