AsyncTcpConnection IP可能会变化,对最后一个IP有保存,但是当IP变了后,连接老的IP会要30秒才知道不能连接,能否设置连接操作几秒,没成功,就代表该IP无效,需要重新获取IP
用定时器
$con = new AsyncTcpConnection(...); $con->onConnect = function($con){ $con->connected = true; }; $con->connect(); Timer::add(30, function()use($con){ if (empty( $con->connected )) { echo "connect timeout"; } }, null, false);
用定时器