Ticket #2880: phpagi-asmanager.php.diff
| File phpagi-asmanager.php.diff, 1.5 kB (added by mickecarlsson, 3 years ago) |
|---|
-
phpagi-asmanager.php
old new 224 224 $this->port = $this->config['asmanager']['port']; 225 225 } 226 226 227 // connect the socket 227 // connect the socket, set a 10 second timeout for the connection, this gives us plenty of time to connect 228 228 $errno = $errstr = NULL; 229 $this->socket = @fsockopen($this->server, $this->port, $errno, $errstr );229 $this->socket = @fsockopen($this->server, $this->port, $errno, $errstr, 10); 230 230 if($this->socket == false) 231 231 { 232 232 $this->log("Unable to connect to manager {$this->server}:{$this->port} ($errno): $errstr"); 233 233 return false; 234 } 235 234 } else 235 // Set a 2 second timeout for read/write commands 236 stream_set_timeout($this->socket, 2); 237 236 238 // read the header 237 239 $str = fgets($this->socket); 238 240 if($str == false) … … 251 253 if($res['Response'] != 'Success') 252 254 { 253 255 $this->log("Failed to login."); 254 $this->disconnect( );256 $this->disconnect(TRUE); 255 257 return false; 256 258 } 257 259 return true; … … 262 264 * 263 265 * @example examples/sip_show_peer.php Get information about a sip peer 264 266 */ 265 function disconnect( )267 function disconnect($dontlogoff=NULL) 266 268 { 269 if (!$dontlogoff) 267 270 $this->logoff(); 268 271 fclose($this->socket); 269 272 }
