Check server availability using fsockopen before attempting to actually connect.

feature/node-rewrite
Sven Slootweg 12 years ago
parent 11579a8ea0
commit d77b72be83

@ -78,7 +78,14 @@ class SshConnector extends CPHPBaseClass
public function Connect() public function Connect()
{ {
/* TODO: Use fsockopen with a timeout to determine if the node and SSHd are reachable before attempting to connect. */ $fp = @fsockopen($this->host, $this->port, $errno, $errstr, 3);
if(!$fp)
{
throw new SshConnectException("Could not connect to {$this->host}:{$this->port}: {$errstr}");
}
fclose($fp);
$options = array( $options = array(
'hostkey' => $this->keytype 'hostkey' => $this->keytype

Loading…
Cancel
Save