Android Question How to check whether FTP connected

vecino

Well-Known Member
Licensed User
Longtime User
Hello, with the following code attempts to connect to an FTP server.
B4X:
FTPpro.Initialize("ftppro",cHost,iPort,cUser,cPassword)
If there is some problem and can not connect. How do I control it?
I need something like this:
B4X:
bResult = FTPpro.Initialize("ftppro",cHost,iPort,cUser,cPassword)
bResult boolean variable is true or false. Successful connection or not.
Is it possible to do something similar?
 

eurojam

Well-Known Member
Licensed User
Longtime User
you can send the NOOP command and use the commandCompleted event
B4X:
FTPpro.SendCommand("NOOP","")
and then
B4X:
Sub ftp_CommandCompleted ( Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
    Log("Command " & Command & " Success " & Success  & " Replycode " &  ReplyCode & " Replystring " & ReplyString)
    If ReplyCode = 200 Then
        'ok
    Else
        'something wrong...
    End If      
End Sub
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hi, thanks for your response.
I do something similar like that.
But it does not work because the problem is that if you can not connect, it is "waiting endlessly" and never returns an error message.
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
when I make this connect:
B4X:
oFTP.Initialize( "FTP","mymikeymouse.com", 21, "abc", "def")
I will get this response:
Command NOOP Success false Replycode 0 Replystring .... so I know, something strange happend or Mickey Mouse was not at home
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Sorry, I do not know English (translate.google). But now I think I understand. I'll try.
Thank you.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hello, thanks for the help, it works perfectly.
I discovered that the problem is elsewhere. Connecting via wifi works well. Connecting with "mobile data" does not work downloading files.
Any ideas?
Thank you
 
Upvote 0
Top