OpenSSL renegotiation using select and multiple blocking sockets -


i have server thread uses multiple blocking sockets , need run when there's data process. problem is, how let openssl "its stuff" (like renegotiation) without getting stuck in blocking operation (awaiting application data)? note: have ssl_set_mode - ssl_mode_auto_retry , suspect i'll need not , handle cases myself, it's not clear reading documentation how i'd accomplish that. consider following pseudo-code:

while(running){     select on readability sockets 1 , 2     if(socket 1 readable) {         ssl_read data(socket 1)         process data, possibly interacting socket 2     }     if(socket 2 readable) {         ssl_read data(socket 2)         process data, possibly interacting socket 1     } } 

what happens if select drops out because there's ssl/tls-layer "things do" on either socket not application-layer data? ssl_read handle "things do", block because there's no application data... block kills ability read other socket. there's nice method ssl_pending tell me application data, stack doesn't chance data without ssl_read far can tell. apart separating sockets separate threads or using non-blocking sockets, there easy way openssl layer "do renegotiation if need to, , read data records if there don't block if neither needed"? null/null read or write?

// process records on socket ssl_read( ssl, 0, 0 ); // or maybe ssl_write( ssl, 0, 0 ) ? if ( ssl_pending( ssl ) ) {     // application data read     ssl_read( ssl, buf, sizeof(buf) ); } 

edit: tried out doing ssl_read( ssl, 0, 0 ) without select-read , blocks record won't work. doing select read-0/0 or ssl_write( ssl, 0, 0 ) without select seems not blocking, although i'm not sure yet either doing need do...

ssl_pending read ahead not purpose using. blocking read automatically renegotiate when ever next read done. if using ssl_set_fd can set recieve timeout on descriptor , might in case. how set socket timeout in c when making multiple connections?

otherwise non blocking io can used.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -