lithium\net\socket\Context::write PHP Méthode

write() public méthode

Writes to the socket.
public write ( string $data = null ) : boolean
$data string Data to write.
Résultat boolean Success
    public function write($data = null)
    {
        if (!is_resource($this->_resource)) {
            return false;
        }
        if (!is_object($data)) {
            $data = $this->_instance($this->_classes['request'], (array) $data + $this->_config);
        }
        return stream_context_set_option($this->_resource, $data->to('context', array('timeout' => $this->_timeout)));
    }

Usage Example

Exemple #1
0
	public function testWriteAndRead() {
		$stream = new Context($this->_testConfig);
		$this->assertTrue(is_resource($stream->open()));
		$this->assertTrue(is_resource($stream->resource()));
		$this->assertEqual(1, $stream->write());
		$this->assertPattern("/^HTTP/", (string) $stream->read());
	}