How can I check for close notify from the server before sending the request #21861
-
I'm using OpenSSL 3.0.9. I'm trying to write C++ code that does this:
When the server timeout ends, it sends a "close notify" notification and the application closes responding. However, in my code, the only way to get the message is How can I find out about the connection status before sending the request? How can I initialize the connection status? Is it possible to do this with blocking bio? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Your suggested answer in that stack overflow question is the correct approach for using a blocking socket (or alternatively to Alternatively, you can of course use a non-blocking socket. |
Beta Was this translation helpful? Give feedback.
-
My suggested answer is incorrect when the close notify received after checking before sending the request. Then, my client sends the request. I see it in Wireshark. However, the server doesn't receive it. Therefore, my read method returns 0. I'm already getting these errors in practice. It doesn't feel right to me. I'm trying to understand the openssl s_client source code, but it's hard. |
Beta Was this translation helpful? Give feedback.
Your suggested answer in that stack overflow question is the correct approach for using a blocking socket (or alternatively to
select
you can usepoll
/epoll
/whatever). There is a risk that the peer only sends "half" a record in which caseselect
will indicate that the socket is readable and then the application will read the first half of the record, but then block waiting for the rest of the record to arrive - but that doesn't normally happen with a well behaved peer.Alternatively, you can of course use a non-blocking socket.