Ethson Liu
Ethson Liu
After called `mosquitto_publish`, you can free the payload memory. https://github.com/eclipse/mosquitto/blob/f1bf2938b047b80913c8a37f088b27e812e0f8b7/lib/actions.c#L148
> I don't want to reapply for memory. I want to use the existing memory to send it at one time.(Too little memory) You can reuse the existing memory, but...
你的问题不是不想每次 pub 的时候都 malloc 一段内存么?那就重用啊,但是重用需要注意得等 publish 做完才可以。至于文本和图片是分开还是一起发送都可以,看自己的需要。但是图片是 binary datas,mosquitto 是要验证是否符合 utf8 格式的(具体搜索 `mosquitto_validate_utf8` 的调用处),你可能需要转成 base64 编码,再搞个压缩也行,具体带来的时空复杂度需要自己衡量。
抱歉,我理解错你的问题了。 目前没有接口可以满足你的需求,你只能把两段内存合为一段连续的传给 `mosquitto_publish`
This is practical for clients, especially on Windows.
@ralight Hi, ```c++ libmosq_EXPORT int mosquitto_tls_set(struct mosquitto *mosq, const char *cafile, const char *capath, const char *certfile, const char *keyfile, int (*pw_callback)(char *buf, int size, int rwflag, void *userdata)); ```...
I implemented it, pls see
Hi, @ralight , long time no see. What's meaning of `MOSQ_OPT_CLEAN_START`? Clean session?