Description:
------------
If connecting to a host, there's no way to spefify a timeout. This will halt the script in the worst case.
PHP's ftp_* functions support timeouts since 4.2...

Comments

[2004-02-17 00:53 UTC] pear-dev at mocsnik dot hu

reviewed.
some help for toby :)
timeout may be set on ftp_connect() and changed later using ftp_set_option($conn_id, FTP_TIMEOUT_SEC, $value);
No reason to have $_timeout, work with runtime FTP options directly.
function connect ( $host = null, $port = null, $timeout = FTP_TIMEOUT_SEC )
{
[..]
$handle = @ftp_connect($this->getHostname(), $this->getPort(), $timeout);
[..]
}
/**
* Set the timeout
*
* @access public
* @param int $timeout Timeout to set
*/
function setTimeout ( $timeout ) {
ftp_set_option($this->_handle, FTP_TIMEOUT_SEC, $timeout);
}
/**
* Returns the timeout
*
* @access public
* @return int $timeout Current timeout value
*/
function getTimeout ( ) {
return ftp_get_option($this->_handle, FTP_TIMEOUT_SEC);
}
more info from the php manual:
"[FTP_TIMEOUT_SEC is a constant] defined by this [=ftp] extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. "
IMHO there's no sense of using Net_FTP package without this extension so this note can be ignored.
"FTP_TIMEOUT_SEC (integer)
See ftp_set_option() for information."
-> "FTP_TIMEOUT_SEC Changes the timeout in seconds used for all network related functions. value must be an integer that is greater than 0. The default timeout is 90 seconds."
--
if you are already in the source please remove one of these duplicated lines:
* Set the Username
* Set the Username

This bug has been fixed in CVS.
In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pear.php.net.
In case this was a pear.php.net website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PEAR better.