Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a problem with receiving files on a socket for some reason hopefully someone will know why.

 

After connecting to a ftp sever I download files using the following code.

 

           Do
               BytesRemaining = PasvSocket.Receive(ReceiveBuffer, 512, SocketFlags.None)
               BytesReceived += BytesRemaining
               MyFile.Write(ReceiveBuffer, 0, BytesRemaining)
               RaiseEvent DownloadProgress(RemoteFilename, BytesReceived, FileSize)
               Application.DoEvents()
           Loop Until (BytesRemaining = 0)

 

The problem is SOMETIMES not all the time when downloading files, the program will hang on the line

 

               BytesRemaining = PasvSocket.Receive(ReceiveBuffer, 512, SocketFlags.None)

 

And the program will freeze waiting for PasvSocket to receive anything. This does not happen all the time and therefore I am completely baffeled.

 

Any ideas? Many thanks

 

Andy

Code today gone tomorrow!
Posted

Well apart from the above ... and the above only seams to happen on one ftp server strange :? anyway find attached a usable version on the control with a small client also wrote to see how to use it anyway its fairly simple to use you can download/upload a file just using 6 lines of code

 

for example

 

       Dim MyFTP As New classFTP
       If MyFTP.Connect("ftp.microsoft.com", "anonymouse", "test@test.com", "reskit/win2000") Then
           MyFTP.DownloadFile("now.zip", "now.zip")
       Else
           MsgBox("Could not connect", MsgBoxStyle.Information, "Error Connecting")
       End If

 

Anyway please feel free to change/modify it. If this control helps please tell me.

 

Andy

 

p.s I know there are some bugs in getting the Directory listings from a couple of severs I am working on this.

ftp.zip

Code today gone tomorrow!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...