programming ftp: how to abort file transfer?
i am doing s开发者_如何学Gomall ftp client for recieving some big files from ftp. I have read in RFC that ABOR command is very problematic for servers. Almost all servers i see just continue to send data even after ABOR sent through control connection. Closing the data transfer can result (in 70% of tests) in closing control connection also. The server just sends FIN packet after my pushed ABOR packet. What is the best good method to stop recieving at some byte and not lose the control connection? FlashFXP doing this ok on all types of connection delays and servers. While investigating tcp traffic i found standard ftp rfc flow.
But in my case still no success to abort transfer using this technique:
1) shutdown(passive_socket, SD_BOTH)
2) closesocket(passive_socket);
3) send(control_socket,"ABOR\r\n")
4) recv(control_socket) - stalled here
Thank you
The "ABOR\r\n" command should be sent as out-of-band data. In case of send() -
send(control_socket, "ABOR\r\n", 6, MSG_OOB);
Some time after you recv() code 426 Transfer aborted. Data connection closed.
The following link is more helpful if you can't achieve success aborint transfer: http://www.developer.nokia.com/Community/Discussion/showthread.php?134079-Telnet-quot-Interrupt-Process-quot-(IP)-signal-amp-Telnet-quot-Synch-quot
You should not lose your control connection when closing the data transfer connection, they are two separate sockets. Maybe check your code to see why the control connection is being closed.
精彩评论