上代碼
$connection = new AsyncTcpConnection('tcp://baidu.com:81');
// 執(zhí)行連接的時(shí)候還沒設(shè)置onError回調(diào)
$connection->connect();
$connection->onError = function($connection, $err_code, $err_msg)
{
echo "$err_code, $err_msg";
};
報(bào)錯(cuò)
ThrowableError?in?AsyncTcpConnection.php line 203 致命錯(cuò)誤: Call to a member function add() on null
if ($this->_status === self::STATUS_CLOSING) {
$this->destroy();
}
if ($this->_status === self::STATUS_CLOSED) {
$this->onConnect = null;
}
return;
}
// Add socket to global event loop waiting connection is successfully established or faild.
Worker::$globalEvent->add($this->_socket, EventInterface::EV_WRITE, array($this, 'checkConnection'));
// For windows.
if(DIRECTORY_SEPARATOR === '\\') {
Worker::$globalEvent->add($this->_socket, EventInterface::EV_EXCEPT, array($this, 'checkConnection'));