Comments (9)
Thank you all,
I will implemented a fd select() to call mqtt_sync.
from mqtt-c.
I'm not Liam, but I don't think one exists natively. However, you possibly could implement one by polling the socketfd
in your mqtt_client
instance using poll
, select
, or epoll
if your platform supports it. Once one of those functions indicates that socketfd
has data to be read, you could then call mqtt_sync
.
from mqtt-c.
I don't think this is a priority at all. In fact, I'm not actually sold on it being a good idea at all.
I'm going to close this issue for the time being, but if anyone does want this functionality, feel free to reopen ๐
from mqtt-c.
Yeah, @Josh798 is correct. Currently, no, but it probably wouldn't be much work to add. Unfortunately though, right now I don't have the capacity to do this myself.
MQTT-C currently supports non-blocking sockets because mqtt_sync
is intended to be called in a busy loop. Part of the reason for this is MQTT-C can run in single-threaded applications (no OS), and doing that with non-blocking sockets is considerably easier than with blocking sockets.
One thing thoughโyou don't need to call mqtt_sync
very frequently. For QoS 0 mqtt_sync
only needs to be called about as frequently as you expect traffic. For higher QoS's you should be calling mqtt_sync
a few times per second.
from mqtt-c.
Great, that would be awesome!
Looking forward to your PR.
Liam
from mqtt-c.
Hi, Just wondering how you're making out with this. Are you still working on this?
from mqtt-c.
If nobody is currently working on this, I can take a shot at this in my spare time. But, my spare time is quite limited at the moment, so I might be a while if so.
from mqtt-c.
@LiamBindle I need this functionality because I'm working with single-threaded applications with an event loop(interrupts from timers, uart, network, internal threads, etc send events to the loop to unblock it for one iteration).
I like that concept because it allows me to not worry about thread-safety while still having low cpu-load when there's nothing todo.
I've already started working on it but I'm not sure how this could be merged because it needs quite a few changes to the way mqtt-c works. You can take a look here:
https://github.com/M1cha/MQTT-C/tree/eventloop
from mqtt-c.
Hi Michael,
Oh cool! Let me know how it goes!
Down the road, if you do want to merge it into the official MQTT-C repo, you could define a flag in the PAL that indicates if the network callbacks are blocking or non blocking. Then, in the MQTT-C source code handle the two separately. That would be my recommendation, but I good with whatever you decide to do.
The two benefits of merging it into the offical MQTT-C repo would be helping other users (there's been a handful of people that want to use blocking sockets) and benefiting from upstream developments. For example, if someone were to add MQTT-SN or MQTT 5 support, you/the users your dev supports could quickly benefit from that.
Anyways, hope it's going well! Let me know if you need a hand with anything!
Liam
from mqtt-c.
Related Issues (20)
- Would reconnect_publisher be a thing? HOT 3
- Adding contex to callbacks HOT 1
- Insufficient validation of PUBLISH message HOT 2
- Possible undefined behaviour/bad memory access after reconnect HOT 2
- MQTT_ERROR_SEND_BUFFER_IS_FULL due to transient MQTT_ERROR_SOCKET_ERROR
- FPU-Trap when calculating client->typical_response_time
- mqtt_publish return value causes mqtt_error_str when not connected
- mqtt_publish seems to only send QoS 0 HOT 1
- Possible bug in MQTT_CLIENT_TRY_PACK macro
- MQTT-C Security Issue Report (mqtt_unpack_publish_response) HOT 2
- swap use of double variables to float HOT 1
- How to check the client has received a Connack from the Broker after connect() HOT 7
- how to check network connection state in inspector callback
- Signed integer overflow in `mqtt_error_str()` HOT 2
- We cannot pass the context of the program to mqtt publish_callback HOT 2
- Mingw compile error
- Memory alignment in Keil ARM Compiler (thumb instruction set)
- mqtt_connect does not generate a client.error if wrong username and/or password is provided
- Unable to connect openssl_publisher example to HiveMQ HOT 2
- Windows MSYS2 MINGW64: Examples fail with "MQTT_ERROR_SOCKET_ERROR" or "Failed to open socket: : No error"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqtt-c.