本文整理汇总了PHP中SimpleSocket::isError方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSocket::isError方法的具体用法?PHP SimpleSocket::isError怎么用?PHP SimpleSocket::isError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleSocket
的用法示例。
在下文中一共展示了SimpleSocket::isError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBadSocket
public function testBadSocket()
{
$socket = new SimpleSocket('bad_url', 111, 5);
$this->assertTrue($socket->isError());
$this->assertPattern('/Cannot open \\[bad_url:111\\] with \\[/', $socket->getError());
$this->assertFalse($socket->isOpen());
$this->assertFalse($socket->write('A message'));
}
示例2: testSocket
function testSocket()
{
$socket = new SimpleSocket("www.lastcraft.com", 80);
$this->assertFalse($socket->isError(), "Error [" . $socket->getError() . "]");
$this->assertTrue($socket->isOpen());
$this->assertTrue($socket->write("GET www.lastcraft.com/test/network_confirm.php HTTP/1.0\r\n"));
$socket->write("Host: localhost\r\n");
$socket->write("Connection: close\r\n\r\n");
$this->assertEqual($socket->read(8), "HTTP/1.1");
$socket->close();
$this->assertEqual($socket->read(8), "");
}
示例3: fetch
/**
* Fetches the content and parses the headers.
* @param $socket Test override.
* @return Either false or a HttpResponse.
* @access public
*/
function fetch($socket = false)
{
if (!is_object($socket)) {
$socket = new SimpleSocket($this->_url->getHost());
}
if ($socket->isError()) {
return false;
}
$socket->write("GET " . $this->_url->getPath() . $this->_url->getEncodedRequest() . " HTTP/1.0\r\n");
$socket->write("Host: " . $this->_url->getHost() . "\r\n");
foreach ($this->_user_headers as $header_line) {
$socket->write($header_line . "\r\n");
}
if (count($this->_cookies) > 0) {
$socket->write("Cookie: " . $this->_marshallCookies($this->_cookies) . "\r\n");
}
$socket->write("Connection: close\r\n");
$socket->write("\r\n");
return $this->_createResponse($socket);
}