VB 6.0 - Winsock Error in implementing FTP download...

Asked By pampati praveen on 28-Apr-03 10:03 AM

I have developed a ftp client programme using MSWinsock control in vb6. Everything goes fine. But, in case of donwloading a file in intranet, data socket is getting closed before getting Full file. so for this, on close event of data socket, i added a check that whether the full file received or not, if received i am closing if not leaving. in this case, socket state is already changed to sckClosing , but still dataarrival event occours. But, if I try to retrieve data using Getdata method, it generates an error:40006-Wrong protocol or connection state for the requested transaction or request, because of socket state is changed and it is in closing state.
can any one please help me in fixing this bug..? is this the winsock control Bug?
If so, is there fix for this?

Thanking you in advance.


The bug is in the premature close... - Asked By Chris Falter on 29-Apr-03 12:43 AM

Praveen -

The "bug" you have described is actually the expected behavior.  Once you reach the sckClosing state, you cannot call Getdata any more.

On the other hand, you obviously should not be reaching the sckClosing state.  When I worked at MS, the winsock control was notorious for its unpredictable behavior.  You might try a third-party socket control such as SocketWrench (http://www.simtel.net/pub/pd/60454.html) or Mabry Socket/X (http://download.com.com/3000-2070-4434701.html?tag=lst-0-9)   I also noticed a couple of ftp client controls at http://download.com.com/3150-2070-0-1-0.html?qt=zdvb&tag=dir.

Thank you very much Chris.. - Asked By pampati praveen on 30-Apr-03 07:04 AM

I downloaded Sockewrench and implemented FTP CLient with the same. It works fine.

Thankyou verymuch