Hi everyone
I need to know if there is a way to know if the connection made to an FTP was successful. because if I try to put the wrong FTP address and execute FTP1.Initialize with all the relative parameters, I don't get any response to know if I'm connected to the FTP server or not....
This is because I would like to test if the FTP server is online before starting to transfer or read data...
I tried to PING but it takes too long...
Is there a way?
A thousand thanks
FTP1.Initialize doesn't connect to the ftpserver. you can use FTP1.List(".") to check whether the ftpserver has been connected. if a wrong address is given, it will take 120s for timeout.
Dim ftp As FTP
ftp.Initialize("ftp", "ftp.domain.com", 21, "user", "password")
Dim sf As Object = ftp.SendCommand("ACCT", Null)
Wait For (sf) ftp_CommandCompleted (Command As String, Success As Boolean, ReplyCode As Int, ReplyString As String)
Log(Command & "->" & Success & "->" & ReplyCode & "->" & ReplyString)
edit: I am not familiar with FTP but maybe can try some commands like NOOP, PWD or STAT
The FTP protocol has quite some commands that can be used: ABOR - abort a file transfer CWD - change working directory DELE - delete a remote file LIST - list remote files MDTM - return the modifi...
A similar question was asked a few weeks ago. This was my suggestion . . .
1. Set the FTP timeout to, say, 200msec.
2. Try to send a dummy test file, just a few bytes.
3. If the FTP link times out you can tell that you do not have a connection.
4. If the dummy file transfer succeeds reset the timeout to something sensible, say 5000.
A similar question was asked a few weeks ago. This was my suggestion . . .
1. Set the FTP timeout to, say, 200msec.
2. Try to send a dummy test file, just a few bytes.
3. If the FTP link times out you can tell that you do not have a connection.
4. If the dummy file transfer succeeds reset the timeout to something sensible, say 5000.