Skip to content

How can I check for close notify from the server before sending the request #21861

Closed Answered by mattcaswell
SergeyKiwi asked this question in Q&A
Discussion options

You must be logged in to vote

Your suggested answer in that stack overflow question is the correct approach for using a blocking socket (or alternatively to select you can use poll/epoll/whatever). There is a risk that the peer only sends "half" a record in which case select 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.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@SergeyKiwi
Comment options

Answer selected by SergeyKiwi
Comment options

You must be logged in to vote
2 replies
@mattcaswell
Comment options

@SergeyKiwi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants