Results 1 to 4 of 4

Thread: Problems with making an FTP Client with VB

  1. #1

    Thread Starter
    Addicted Member Frankie902's Avatar
    Join Date
    Feb 2001
    Location
    Lindenwold, NJ, USA
    Posts
    217

    Problems with making an FTP Client with VB

    I am working on an FTP client using the MS Winsock Control, I used this code and having my winsock control set to the nbci ftp server (ftp.nbci.com):
    Code:
    Private Sub Form_Load()
    Winsock1.Connect
    Text1.Text = Text1.Text & vbCrLf & "Connecting"
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Winsock1.Close
    End Sub
    
    Private Sub Winsock1_Close()
    MsgBox "Connection Closed"
    End Sub
    
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim sString As String
    Winsock1.GetData sString, vbString
    Text1.Text = Text1.Text & vbCrLf & sString
    Select Case Left(sString, 3)
    Case "220"
    Winsock1.SendData "USER fwninc"
    Text1.Text = Text1.Text & vbCrLf & "USER fwninc"
    End Select
    
    End Sub
    I Get this in my text Box.

    Connecting
    220 ftp.xoom.com FTP server (Version XOOM FTP 1.24.3+local-release Fri Aug 28 15:52:40 PDT 1998.) re
    USER fwninc
    ady.


    I dont know why it goes re and then on the bottom ady. it should be "ready.", and how come I dont get a "331 Password required for fwninc."?
    Please help!
    Using:
    Visual Studio .Net Enterprise
    Visual Basic 6.0 Enterprise

  2. #2
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    I do not know how to answer your question but here is some sample apps.
    Attached Files Attached Files

  3. #3
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    Sample 2.
    Hope that this helps.
    Attached Files Attached Files

  4. #4
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    I made a few modifications to your DataArrival event.

    Step One: put a global variable in your project --
    Code:
    Dim fullDataString as String
    Step Two: Do this with your DataArrival event

    Code:
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim sString As String
    Winsock1.GetData sString, vbString
    ' Here's something new
    fullDataString = fullDataString & sString
    If right$(fullDataString,2) = vbCrLf Then
        Text1.Text = Text1.Text & sString   ' You can take out the vbCrLf here...
        Select Case Left(sString, 3)
            Case "220"
                ' This is new too!
                Winsock1.SendData "USER fwninc" & vbCrLf
                Text1.Text = Text1.Text & "USER fwninc" & vbCrLf   ' ...but just reposition it here
        End Select
        fullDataString = ""
    End If
    End Sub
    What this does is wait for the entire communication to come in. FTP, mail, and a lot of internet servers terminate their data transmissions with a CR+LF pair, so you have to check to see if the CRLF is in before you can work with it. Also, in all of your *.SendData statements, put a vbCrLf on the end of them so the server knows what's going on
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width