PDA

Click to See Complete Forum and Search --> : vb2008 and ftp


zdelete
May 15th, 2010, 04:33 PM
Hello i am currently developing a program where u send data to a ftp to server once your connected and it displays the response from the server in a listbox. my problem is that my listbox will only contain the intial banner and nothing else from the ftp server, for example once i connect and send the command USER anonymous, i dont have the response in my listbox which should be 331 Please specify the password. is there any help u guys can provide? im using winsock and will include my code below, thank you





Public



Class Form1




Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click




On Error Resume Next

sock.Protocol = MSWinsockLib.ProtocolConstants.sckTCPProtocol



sock.Connect(txtip.Text, txtport.Text)

ListBox1.Items.Add(

"connecting to " & txtip.Text & ": " & txtport.Text & vbNewLine)




End Sub



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ListBox1.Anchor = AnchorStyles.Top




End Sub



Private Sub sock_ConnectionRequest(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_ConnectionRequestEvent) Handles sock.ConnectionRequest

sock.Close()

sock.Accept(e.requestID)




End Sub



Private Sub sock_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles sock.DataArrival




On Error Resume Next



Dim incoming As String = "data"

sock.GetData(incoming)

ListBox1.Items.Add(incoming & vbNewLine)

incoming = (

"data")






End Sub



Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click




On Error Resume Next

sock.Close()



If sock.CtlState = MSWinsockLib.StateConstants.sckClosed Then

ListBox1.Items.Add(

"disconnected from " & txtip.Text)




End If



End Sub



Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

sock.SendData(


"NOOP")




End Sub



Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

sock.SendData(


"USER anonymous")




End Sub



Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

sock.SendData(


"PASS FLY@ROXX.DE")




End Sub



Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged




End Sub



Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click




On Error Resume Next



Dim contact As Boolean = False

sock.SendData(

CStr(TextBox1.Text))




End Sub

End




Class

zdelete
May 16th, 2010, 06:11 PM
does anyone have any thoughts ?

Mike Stefanik
May 21st, 2010, 09:50 AM
Make sure that you're terminating the commands with a CRLF sequence. FTP (and most application protocols like POP3, IMAP4, SMTP, etc.) expect that the commands that you send end with a carriage-return and linfeed, that's how the server knows the command is complete.

zdelete
May 21st, 2010, 01:44 PM
thank you mike i actually figured that out recently. but it seems i have run into another issue. i aim trying to make my program send data to the server based on the servers response, but i keep running into issues, it seems when i attempt to log into the server my Pass password command is not be sent. but my user command is. maybe u would like to take a look at my code. if so pm me please