Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Set a timeout for _FTP_Connect()

$
0
0
We have several servers and I'm writing a server status monitor.  I am trying to quickly determine if I can FTP to each of our local servers.  When I successfully do an _FTP_Open(), then call _FTP_Connect(), the _FTP_Connect takes around 45 seconds to time out.

I want to make the 'FTP-ability' test to take no more than 1 or 2 seconds.

Is there a way to change the _FTP_Connect() timeout?  Perhaps there is another call I could use?

Here is my sample code (with my server credentials removed).
#include <FTPEx.au3>
#include <array.au3>
_Main()
Exit (0)
Func _Main()
Local $server, $uname, $pwd, $hSession, $iID, $bRet
$server = "xxxxx"
$uname = "xxxxx"
$pwd = "xxxx"
$hSession = _FTP_Open('MyFTP')
If $hSession <> 0 Then
$iID = _FTP_Connect($hSession, $server, $uname, $pwd, 1, 21)
ConsoleWrite("Can connect OK" & @CRLF)
If ($iID <> 0) Then
Else
ConsoleWrite("Connect FAILED" & @CRLF)
EndIf
_FTP_Close($hSession)
Else
ConsoleWrite("+++: Openfailed" & @CRLF)
EndIf
EndFunc ;==>_Main


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>