timeout() public method

Sets the timeout on the socket *connection*.
public timeout ( integer $time = null ) : booelan
$time integer Seconds after the connection times out.
return booelan `true` if timeout has been set, `false` otherwise.
 public function testGetSetTimeout()
 {
     $subject = new Context($this->_testConfig);
     $this->assertEqual(4, $subject->timeout());
     $this->assertEqual(25, $subject->timeout(25));
     $this->assertEqual(25, $subject->timeout());
     $subject->open();
     $this->assertEqual(25, $subject->timeout());
     $result = stream_context_get_options($subject->resource());
     $this->assertEqual(25, $result['http']['timeout']);
 }
Example #2
0
 public function testConstruct()
 {
     $subject = new Context(array('timeout' => 300));
     $this->assertTrue(300, $subject->timeout());
     $subject->close();
     unset($subject);
 }