异步建立一个到实际mysql服务器的连接
$connection_to_mysql = new AsyncTcpConnection($REAL_MYSQL_ADDRESS);
// mysql连接发来数据时,转发给对应客户端的连接
$connection_to_mysql->onMessage = function($connection_to_mysql, $buffer)use($connection$connection->close();
};
// 执行异步连接
$connection_to_mysql->connect();
// 客户端发来数据时,转发给对应的mysql连接
$connection->onMessage = function($connection, $buffer)use($connection_to_mysql)connection)use($connection_to_mysql)
{
$connection_to_mysql->close();
};
// 客户端连接发生错误时