I really don't know how to do in following scene:
1:In Application, we call SSL_write(s, data, 100) want to send 100 bytes plaintext to peer.
2:In openssl, data will be encrypted and expanded to 116 bytes (maybe other size, I don't care)
3:In openssl, after encrypting the input, it call BIO_write/send(tcp layer interface) to send 116 bytes but only 10 bytes sent (may be caused by not enough socket buffer and send() return 10)` .Does OpenSSL cache the 100 ciphertext in it's own buffer ?
What's the SSL_write's return value when the 1 2 3 happen?
1: If SSL_write returns 10 (or again), the application will cache 90 (or 100) bytes plaintext and will call SSL_writeagain to write 90(or 100) bytes plaintext when fd is writable, but this will cause encryption state error because SSL_write has already encrypted all the plaintext.
2: if SSL_write return 100, the application think it has sent all data/plaintext, and may not call select/epoll_add to polling fd's writable event. ( I find Nginx does like this, maybe I'm wrong ) , so how can the application do to flush the remain data in openssl's left data ?