想问下zmq怎么使用

Evan_Lai

手册上的demo,好像我运行了,但是请求不到

2415 1 0
1个回答

yangzai
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to Redis Server sucessfully ";
echo "Redis Server is running: " . $redis->ping();
$context = new \ZMQContext();
$subscriber = new \ZMQSocket($context, \ZMQ::SOCKET_SUB);
$subscriber->connect("tcp://139.199.887.26:56789");
$subscriber->setSockOpt(\ZMQ::SOCKOPT_SUBSCRIBE, "");
echo " zmq Server is running successfully";
while(true) {
    try{
         $data = $subscriber->recv();
         $redis->set('pushMarketListPrice',$data);
    }catch (\Exception $e){
        var_dump($e);
    }
}
  • 暂无评论
年代过于久远,无法发表回答
×
🔝