Rev 1448 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1448 | Rev 1463 | ||
---|---|---|---|
Line 1114... | Line 1114... | ||
1114 | 1114 | ||
1115 | /** |
1115 | /** |
1116 | * Default Constructor. |
1116 | * Default Constructor. |
1117 | * |
1117 | * |
1118 | * $host can either be a string, representing the host, or a stream resource. |
1118 | * $host can either be a string, representing the host, or a stream resource. |
- | 1119 | * If $host is a stream resource then $port doesn't do anything, altho $timeout |
|
- | 1120 | * still will be used |
|
1119 | * |
1121 | * |
1120 | * @param mixed $host |
1122 | * @param mixed $host |
1121 | * @param int $port |
1123 | * @param int $port |
1122 | * @param int $timeout |
1124 | * @param int $timeout |
1123 | * @see self::login() |
1125 | * @see self::login() |
Line 1212... | Line 1214... | ||
1212 | */ |
1214 | */ |
1213 | self::$connections[$this->getResourceId()] = class_exists('WeakReference') |
1215 | self::$connections[$this->getResourceId()] = class_exists('WeakReference') |
1214 | ? \WeakReference::create($this) |
1216 | ? \WeakReference::create($this) |
1215 | : $this; |
1217 | : $this; |
1216 | 1218 | ||
- | 1219 | $this->timeout = $timeout; |
|
- | 1220 | ||
1217 | if (is_resource($host)) { |
1221 | if (is_resource($host)) { |
1218 | $this->fsock = $host; |
1222 | $this->fsock = $host; |
1219 | return; |
1223 | return; |
1220 | } |
1224 | } |
1221 | 1225 | ||
1222 | if (Strings::is_stringable($host)) { |
1226 | if (Strings::is_stringable($host)) { |
1223 | $this->host = $host; |
1227 | $this->host = $host; |
1224 | $this->port = $port; |
1228 | $this->port = $port; |
1225 | $this->timeout = $timeout; |
- | |
1226 | } |
1229 | } |
1227 | } |
1230 | } |
1228 | 1231 | ||
1229 | /** |
1232 | /** |
1230 | * Set Crypto Engine Mode |
1233 | * Set Crypto Engine Mode |
Line 3529... | Line 3532... | ||
3529 | } |
3532 | } |
3530 | throw new ConnectionClosedException($str); |
3533 | throw new ConnectionClosedException($str); |
3531 | } |
3534 | } |
3532 | 3535 | ||
3533 | $start = microtime(true); |
3536 | $start = microtime(true); |
- | 3537 | $sec = (int) floor($this->curTimeout); |
|
- | 3538 | $usec = (int) (1000000 * ($this->curTimeout - $sec)); |
|
- | 3539 | stream_set_timeout($this->fsock, $sec, $usec); |
|
3534 | $raw = stream_get_contents($this->fsock, $this->decrypt_block_size); |
3540 | $raw = stream_get_contents($this->fsock, $this->decrypt_block_size); |
3535 | 3541 | ||
3536 | if (!strlen($raw)) { |
3542 | if (!strlen($raw)) { |
3537 | $this->bitmap = 0; |
3543 | $this->bitmap = 0; |
3538 | throw new ConnectionClosedException('No data received from server'); |
3544 | throw new ConnectionClosedException('No data received from server'); |
Line 4722... | Line 4728... | ||
4722 | } |
4728 | } |
4723 | return false; |
4729 | return false; |
4724 | } |
4730 | } |
4725 | 4731 | ||
4726 | /** |
4732 | /** |
4727 | * Returns all errors |
4733 | * Returns all errors / debug messages on the SSH layer |
- | 4734 | * |
|
- | 4735 | * If you are looking for messages from the SFTP layer, please see SFTP::getSFTPErrors() |
|
4728 | * |
4736 | * |
4729 | * @return string[] |
4737 | * @return string[] |
4730 | */ |
4738 | */ |
4731 | public function getErrors() |
4739 | public function getErrors() |
4732 | { |
4740 | { |
4733 | return $this->errors; |
4741 | return $this->errors; |
4734 | } |
4742 | } |
4735 | 4743 | ||
4736 | /** |
4744 | /** |
4737 | * Returns the last error |
4745 | * Returns the last error received on the SSH layer |
- | 4746 | * |
|
- | 4747 | * If you are looking for messages from the SFTP layer, please see SFTP::getLastSFTPError() |
|
4738 | * |
4748 | * |
4739 | * @return string |
4749 | * @return string |
4740 | */ |
4750 | */ |
4741 | public function getLastError() |
4751 | public function getLastError() |
4742 | { |
4752 | { |