public void activeClose ( TransferContext context , int connections ) { try { //this could be improved; for symmetry and performance, //make it a separate task class and pass to the taskThread for ( int i = 0 ; i < connections ; i ++ ) { SocketBox sbox = socketPool . checkOut ( ) ; try { GridFTPDataChannel dc = new GridFTPDataChannel ( gSession , sbox ) ; EBlockImageDCWriter writer = ( EBlockImageDCWriter ) dc . getDataChannelSink ( context ) ; writer . setDataStream ( sbox . getSocket ( ) . getOutputStream ( ) ) ; // close the socket writer . close ( ) ; } finally { // do not reuse the socket socketPool . remove ( sbox ) ; sbox . setSocket ( null ) ; } } } catch ( Exception e ) { FTPServerFacade . exceptionToControlChannel ( e , "closing of a reused connection failed" , localControlChannel ) ; } }
use only in mode E