Again, this is in the TCP stack. You should probably look at your bio callback implementations.
Sorry for the misunderstanding, I use mbedtls_net_send and mbedtls_net_recv, which are packed within mbedtls package, as callback functions to send/receive packet.
Can you trace where the 0 is returned from? Is it from your bio write callback or from the Mbed TLS code?
My bad, the 0 returned is from another wrapper. The correct behavior is:
- I disconnect my device’s network.
- Then I try to send a PING packet with 2 bytes data.
- The result is that mbedtls_ssl_write returns 2 bytes were written.
Therefore, maybe something wrong with mbedtls_net_send because it doesn’t fire any complaint about missing ACK?
Or mbedtls_ssl_write doesn’t handle errors returned by mbedtls_net_send and I have to handle it by myself?
Edit: I just figured out that mbedtls_net_send uses write, which only returns byte that written into OS kernel. Seem like I have to implement an acknowledgement mechanism on app-level to verify whether the server side receive my message or not.
Thanks alot for you support.