(PECL event >= 1.2.6-beta)
EventBufferEvent::getOutput — 返回与当前缓冲事件关联的底层输出缓冲区
此函数没有参数。
返回与当前缓冲事件关联的 EventBuffer 输出缓冲区的实例。
范例 #1 EventBufferEvent::getOutput() 范例
<?php
$base = new EventBase();
$dns_base = new EventDnsBase($base, TRUE); // 使用异步 DNS 解析
if (!$dns_base) {
exit("Failed to init DNS Base\n");
}
$bev = new EventBufferEvent($base, /* use internal socket */ NULL,
EventBufferEvent::OPT_CLOSE_ON_FREE | EventBufferEvent::OPT_DEFER_CALLBACKS,
"readcb", /* writecb */ NULL, "eventcb", $base
);
if (!$bev) {
exit("Failed creating bufferevent socket\n");
}
$bev->enable(Event::READ | Event::WRITE);
$output = $bev->getOutput();
if (!$output->add(
"GET {$argv[2]} HTTP/1.0\r\n".
"Host: {$argv[1]}\r\n".
"Connection: Close\r\n\r\n"
)) {
exit("Failed adding request to output buffer\n");
}
/* ... */
?>