public function testSocketClosure() { $socket = new SimpleSocket('www.lastcraft.com', 80, 15, 8); $this->assertTrue($socket->isOpen()); $this->assertTrue($socket->write("GET /test/network_confirm.php HTTP/1.0\r\n")); $socket->write("Host: www.lastcraft.com\r\n"); $socket->write("Connection: close\r\n\r\n"); $this->assertEqual($socket->read(), "HTTP/1.1"); $socket->close(); $this->assertIdentical($socket->read(), false); }
public function testSocketClosure() { $socket = new SimpleSocket($this->host, $this->port, 15, 8); $this->assertTrue($socket->isOpen()); $this->assertTrue($socket->write("GET /network_confirm.php HTTP/1.0\r\n")); $socket->write("Host: {$this->host}\r\n"); $socket->write("Connection: close\r\n\r\n"); $this->assertEqual($socket->read(), 'HTTP/1.0'); $socket->close(); $this->assertIdentical($socket->read(), false); }
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), ""); }
function testSocketClosure() { $site = $this->getServerInfo(); $socket = new SimpleSocket($site['host'], $site['port'], 15, 8); $this->assertTrue($socket->isOpen()); $this->assertTrue($socket->write("GET {$site['path']}network_confirm.php HTTP/1.0\r\n")); $socket->write("Host: {$site['host']}\r\n"); $socket->write("Connection: close\r\n\r\n"); $this->assertEqual($socket->read(), "HTTP/1.1"); $socket->close(); $this->assertIdentical($socket->read(), false); }
/** * Reads the whole of the socket output into a * single string. * @param SimpleSocket $socket Unread socket. * @return string Raw output if successful * else false. * @access private */ function _readAll(&$socket) { $all = ''; while (!$this->_isLastPacket($next = $socket->read())) { $all .= $next; } return $all; }
/** * Reads the whole of the socket output into a * single string. * @param SimpleSocket $socket Unread socket. * @return string Raw output if successful * else false. * @access private */ protected function readAll($socket) { $all = ''; while (!$this->isLastPacket($next = $socket->read())) { $all .= $next; } return $all; }
/** * Reads the whole of the socket output into a * single string. * @param SimpleSocket $socket Unread socket. * @return string Raw output if successful * else false. * @access private */ function _readAll(&$socket) { $all = ""; while ($next = $socket->read()) { $all .= $next; } return $all; }