From b125fa0ca129beaf819f10e7399c9878b47e905e Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Wed, 24 Aug 2016 21:27:26 +0200 Subject: Add configuration option to change connection timeout. The timeout can be specified in seconds with the ['timeout'] array index within the router configuration. The default value is 30 seconds. --- auth/telnet.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'auth/telnet.php') diff --git a/auth/telnet.php b/auth/telnet.php index 20b85a6..4aa7a64 100644 --- a/auth/telnet.php +++ b/auth/telnet.php @@ -37,9 +37,11 @@ final class Telnet extends Authentication { } public function connect() { - $this->connection = fsockopen($this->config['host'], $this->port); + $this->connection = fsockopen($this->config['host'], $this->port, $errno, + $errstr, $this->config['timeout']); if (!$this->connection) { - throw new Exception('Cannot connect to router.'); + throw new Exception('Cannot connect to router (code '.$errno.'['. + $errstr.']).'); } fputs($this->connection, $this->config['user']."\r\n"); -- cgit v1.2.3