views:

157

answers:

1

I am doing a project on FTP file-transfer using FtpWebRequest class. While transferring the file, if my network connection gets disconnected the file in the receiving end gets hanged. I am not able to process further even though I re-establish my network connection. After some time the file gets removed; then I am able to put the file again. What is the problem? Is the class is designed in that manner?

Receiving End Means - the machine in which the ftp server runs,and im the who sends the file from a machine without FTP.

+1  A: 

What FTP server you are programming against? I think it is the server who prevents you from manipulating that file (which should be in unknown state) after building up a new connection.

Also when the network connection is disconnected, the underlying WinSock call is still expecting a response from the FTP server. So it hangs there. So if I were you, I will consider async calls, where I can cancel the call if it times out.

Lex Li
hishall i go for asynchronous ftp transfer
karthik
That depends on your application and your choice. Synchronous is easier to use/develop, but asynchronous gives you more flexibilities.
Lex Li
will you give me links to work out,bcoz i have no idea.i have l lotof doubts over it,how to cancel a asyncronous calls,how to time out a connection etc
karthik
You can use BeginGetResponse to send out the request and wait for a response, and check if the response has been received using IAsyncResult.IsCompleted.This MSDN page has a sample similiar,http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.abort(VS.80).aspx
Lex Li