ftp client和ftp server進行文件上傳會建立2條連接(control connectionsdata connections )

control connections : client 對server所下的任何指令 ( tcp/21 )

data connections:資料傳輸 (tcp/20)

client-server連線後保持著control connections等待要求,當需要傳輸檔案時,建立data connections,資料傳送完畢後釋放

控制連接:ftp命令交互

import org.apache.commons.net.ftp.FTPClient;

    FTPClient client = new FTPClient();
    /**
     * client和server的連線逾時時間
     */
    client.setConnectTimeout(connectTimeout);
    /**
     * 非處理資料總時間,data connections中socket阻塞未收到檔案的時間
     */
    client.setDataTimeout(timeout);
    /**
     * control connections數據讀取超時的時間
     * SoTimeout def.-set before connect() 
     */
    client.setDefaultTimeout(timeout);
    /**
     * control connections建立後,重新設置數據讀取超時時間
     * -set after connect() 
     */
    client.setSoTimeout(timeout);

 

ref: http://sudhirvn.blogspot.com/2007/05/ftpclient-timeout-values.html

https://en.wikipedia.org/wiki/File_Transfer_Protocol#cite_note-for-1

https://www.cnblogs.com/dasusu/p/10006899.html

arrow
arrow

    咪卡恰比 發表在 痞客邦 留言(0) 人氣()