问题
With an FTP client I've written I will sometimes receive a 226 Transfer OK
message from the FileZilla server after an upload completes, and sometimes I won't ever receive anything. And it's not that the client disconnected before the 226 Transfer OK
was received, because I can see on the server that FileZilla never sent it.
I need to know when the server has received the complete upload, because I otherwise do not know if the whole file made it to the network before I close the connection.
Any ideas what might cause the unreliability of the 226 Transfer OK
message? What actually triggers it to be sent?
回答1:
I figured it out myself! I found that it's the FIN/ACK
message sent by the client on the data socket port that prompts the FileZilla server to send the 226 Transfer OK
message on the control socket port (after sending its own FIN/ACK
in response on the data socket port).
In WinRT, it's the closing of the data socket that causes the FIN/ACK
message to be sent by the client.
So, the proper order for closing an FTP connection is (after the last data packet is sent) to close the data socket, wait for the 226 Transfer OK
message on the control socket, send the QUIT
message on the control socket, then close the control socket.
来源:https://stackoverflow.com/questions/15343022/dont-always-get-a-226-transfer-ok-at-the-end-of-an-ftp-upload