← Back to team overview

mosquitto-dev team mailing list archive

[Question #174635]: Need help understanding libmqtt code

 

New question #174635 on mosquitto:
https://answers.launchpad.net/mosquitto/+question/174635

Hello,
I am still learning mqtt, and while going through the source code for libmqtt, I am still unable to figure out some basics :

1. I expected mosquitto_connect to make the network connection to the broker - but it is not doing so. The mosquitto_connect_callback_set is getting called only if I call mosquitto_loop. If I am not in a network, I guessed mosquitto_connect would report this back to me immediately, but this is not happening.

2. Due to some issues I wanted mosquitto_loop not to be in an infinite loop. I called mosquitto_loop once and then scheduled it in a timertask after 5 seconds. mosquitto_connect_callback_set is getting called if I call mosquitto_loop "twice". I am wondering what is the correlation with calling it two times...this seems not a random number, I repeated this test for over 50 times.

3. What exactly is the code I should change if I want to know the network failure instantaneously - currently the mosquitto_disconnect_callback_set is not getting called instantaneously (infact it is not even getting called in my case on iOS).

I am trying to make this work on iOS. If someone has already done it, please share your experience. My basic problem is that the mosquitto_loop is continually running, and returning MOSQ_ERR_SUCCESS everytime, even if I go out of network.

Thanks!!

-- 
You received this question notification because you are a member of
Mosquitto Dev, which is an answer contact for mosquitto.