方式1
while (1)
{
int rc = mosquitto_loop(mosq, -1, 1);
if (rc)
{
printf("mqtt_portal: mosquitto_loop rc = %d \n", rc);
sleep(1);
mosquitto_reconnect(mosq);
}
}
方式2
//循环处理网络消息
mosquitto_loop_forever(mosq, -1, 1);
方式1比起方式2优点是如果mosquitto服务器端口后,能够及时打印信息。
标签:方式,Linux,29,mosq,rc,mosquitto,loop From: https://www.cnblogs.com/zhaogaojian/p/16852915.html