c++ - If a winsock2 socket is non-blocking, would an SSL object associated with it also exhibit non-blocking behavior? -
i'm asking question because unsure whether ssl object treats socket sink/source messages bio object. gut telling me yes, i'm not certain.
goal: integrating ssl authentication existing tcp code. rather calling conventional send()/receive(), direct messages through openssl's ssl_read()/ssl_write() instead. other requirement communication non-blocking , data can partially sent.
here's how i've associated ssl object socket (server code).
ssl_init(std::wstring &peer_hostname, socket sock){ //... //initialize ssl structure ssl = ssl_new(context); if (ssl == null){ mr = appzreturn(e_fail, l"%ls (%d) : ssl_new failed. unable create ssl structure", __functionw__, __line__); } //agent uses winsock class, openssl uses unix socket. surpressed warning added here 4244. works if (ssl_set_fd(ssl, sock) == 0){ //set file descriptor ssl //operation failed return -1; } //... int status = ssl_accept(ssl); ssl_set_mode(ssl, ssl_mode_accept_moving_write_buffer|ssl_mode_enable_partial_write); //... }
according documentation ssl_read() [https://www.openssl.org/docs/ssl/ssl_read.html], ssl non-blocking if underlying bio non-blocking. if assumption correct, mean if socket non-blocking, ssl well?
extension of question: winsock tcp socket non-blocking default (assuming have created tcp socket, have not called ioctlsocket , set non-blocking mode)
thank taking time read this. it's appreciated.
if assumption correct, mean if socket non-blocking, ssl well?
yes.
is winsock tcp socket non-blocking default (assuming have created tcp socket, have not called ioctlsocket , set non-blocking mode)
unix sockets default blocking. haven't used winsock. sure winsock should default blocking.
Comments
Post a Comment