Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

programming ftp: how to abort file transfer?

i am doing small 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

like image 484
Sergey Avatar asked Jun 23 '11 16:06

Sergey


People also ask

What is FTP command control?

The ftp command uses the File Transfer Protocol (FTP) to transfer files between the local host and a remote host or between two remote hosts. Remote execution of the ftp command is not recommended. The FTP protocol allows data transfer between hosts that use dissimilar file systems.

What will happen when the given FTP commend is executed?

If you execute the ftp command and specify the host name (HostName) of a remote host, the ftp command tries to establish a connection to the specified host. If the ftp command connects successfully, the ftp command searches for a local $HOME/. netrc file in your current directory or home directory.


1 Answers

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

like image 136
Sergey Avatar answered Sep 30 '22 09:09

Sergey