DataInputStream din = null;
if(sync) {
InputStream in = socket.getInputStream();
din = new DataInputStream(in);
}
final DataOutputStream dos = new DataOutputStream(out);
final StopWatch sw = new StopWatch();
FileInputStream src = null;
final long nbytes;
try {
src = new FileInputStream(file);
FileChannel fc = src.getChannel();
String fileName = file.getName();
IOUtils.writeString(fileName, dos);
IOUtils.writeString(writeDirPath, dos);
long xferBytes = (count == -1L) ? fc.size() : count;
dos.writeLong(xferBytes);
dos.writeBoolean(append); // append=false
dos.writeBoolean(sync);
if(handler == null) {
dos.writeBoolean(false);
} else {
dos.writeBoolean(true);
handler.writeAdditionalHeader(dos);
}
// send file using zero-copy send
nbytes = fc.transferTo(fromPos, xferBytes, channel);