Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.0a3

Bug #723 Timeout for connect cannot be set
Submitted: 2004-02-10 06:56 UTC Modified: 2004-03-14 08:16 UTC
From: schst Assigned: toby
Status: Closed Package: Net_FTP
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2004-02-10 06:56 UTC] schst
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-16 19: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
 [2004-02-17 15:36 UTC] pear-dev at mocsnik dot hu
grr.. validation.. "FTP_TIMEOUT_SEC: value must be an integer that is greater than 0." function setTimeout ( $timeout ) { if ( (is_int($timeout)) && ($timeout > 0) ) ftp_set_option($this->_handle, FTP_TIMEOUT_SEC, $timeout); } else { return new PEAR_Error('Timeout has to be an integer > 0'); } }
 [2004-03-14 08:16 UTC] toby
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.