public void close() throws IOException {
   if (channel != null) {
     channel.close();
   }
   if (client != null) {
     client.replay = null;
     client.close();
   }
 }
 public void nextFrame() throws IOException {
   if (!client.writeBusy()) {
     int nextPos = buffer.position();
     nextPos = Math.min(nextPos + frameSize, fileSize);
     buffer.limit(nextPos);
     client.write(buffer, false);
     if (nextPos >= fileSize) {
       this.close();
     }
   }
 }