我正在思考JSch库使用的一个示例,可以在这里找到:
http://www.jcraft.com/jsch/examples/ScpFrom.java.html
我无法理解这个示例中的几个代码模式。它们是:
Is there any reasons to prefer SCP over SFTP, which can be ran using the same library?
Why we run
scp -f <remote file>
on remote host instead of running simplyscp source_file_path destination_file_path
? Why execution on remote host is better?In the beginning of the transfer there is a line
while(true){ int c=checkAck(in); if(c!='C'){ break; } ...
what is the meaning of this magical
C
letter? WhyC
?Why to send this signal all the time?
// send '\0' buf[0]=0; out.write(buf, 0, 1); out.flush();
how this can read filesize?
long filesize=0L; while(true){ if(in.read(buf, 0, 1)<0){ // error break; } if(buf[0]==' ')break; filesize=filesize*10L+(long)(buf[0]-'0'); //What is this?? }