Weird problem with Socket.Receive

a_jam_sandwich

Well-known member
Joined
Dec 10, 2002
Messages
367
Location
Uk
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.

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

Code:
                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
 
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

Code:
        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.
 

Attachments

Back
Top