passive mode - FTP data connections reuse -
i working on ftp client kicks , trying understand workflow of data connections.
as understand, initial (command
) connection permanent until quit. however, unsure of data connection - re-initiated per-command? call port ...
or pasv
, second connection, list
, results, connection closes, start over?
also, need call pasv
(or port ...
) again after each connection closes? seems when try test things out using passive connection, cannot re-connect same port after first command has returned results , closed data connection. can keep calling pasv
-> data connect -> run command -> results -> data connection closed -> pasv
, seems it's not how it's meant run?
also, if has material on ftp more terse rfc appreciate it.
you have open new connection every time. it's closing of connection, how (or server) can tell transfer completed (at least in common "stream mode").
you cannot reuse local/remote port number combination, when tcp connection closed, enters time_wait mode , port number combination cannot used time. 2 consecutive transfers have use different port number combination anyway.
refer rfc 959, section 3.3. data management:
reuse of data connection: when using stream mode of data transfer end of file must indicated closing connection. causes problem if multiple files transfered in session, due need tcp hold connection record time out period guarantee reliable communication. connection can not reopened @ once.
there 2 solutions problem. first negotiate non-default port. second use transfer mode.
a comment on transfer modes. stream transfer mode inherently unreliable, since 1 can not determine if connection closed prematurely or not. other transfer modes (block, compressed) not close connection indicate end of file. have enough ftp encoding data connection can parsed determine end of file. using these modes 1 can leave data connection open multiple file transfers.
see also:
Comments
Post a Comment