FtpPutFile never timeouts

G

Guest

Private Declare Function FtpPutFile Lib "wininet.dll" (ByVal hConnect As
Integer, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String,
ByVal dwFlags As Integer, ByVal dwContext As Integer) As Boolean


When i use FtpPutFile to send a file the the ftp server, and the internet
connection is lost during the trasfer, FtpPutFile does not timeout and return
False like it should. It will sit there forever and never return.
I don't have any problem while using other wininet functions while internet
connection is lost like FtpSetCurrentDirectory and InternetConnect. They
timeout in about 5 seconds and they return false like they should.
I have tried using FtpOpenFile and InternetWriteFile as a replacement for
FtpPutFile but i get the same problem, it never timeouts when internet
connection is lost during a transfer.
Is this a known bug for wininet and is there a workaround?
 
G

Guest

The solution provided at the end of that thread is done in vb 6.0 and i don't
think there is a way to convert it to vb.net. Since vb 6.0 doesn't have
threading, it uses some callback function to and Timers instead. What i can
try to do is create a separate thread that sends "NOOP" commands to the ftp
server every minute to see if i'm still connected. The thread that is calling
FtpPutFile then needs to be terminated when the first thread is unable to
send "NOOP" to the server, and there is no way to terminate threads in the
compact framework.
 
P

Peter Foot [MVP]

You could use the ThreadEx class (www.opennetcf.org/sdf/) which does have an
Abort method - be aware that generally calling abort on a thread is bad
practice and to highlight this fact the class will throw a
BestPractiseViolationException which you'll need to catch.

Peter
 
G

Guest

Yes, this is the reason i don't want to use that solution, it's a dirty fix
and can caues all sorts of problems in my App. There has got to be a better
way to do it. I don't see why they havent came out with a fix for the
wininet.dll so that the FtpPutFile does timeout. Is this bug ever going to be
fixed?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top