Mbedtls_ssl_read returns 0 can you explain how it's different from close notify

mbedtls_ssl_read returns 0 if the read end of the underlying transport was closed, but isn’t specific if it was closed unclean without the close notify. Can you clarify what the difference is between returning 0 and MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY? Does returning 0 give any indication whether or not a close notify was received? This is currently being discussed at the curl project.

Hi Ray,
As you can see from our example, when mbedtls_ssl_read() returns 0, it’s mostly because the connection was reset by peer, and you should try to reconnect.
0 is returned when the read cb function returns EOF. It is not necessarily because the remote peer gracefully shut down the connection, and is not returned when the Close Notify warning has been received.
Regards,
Mbed TLS Team member,
Ron