It was observed via CI that on Mac OS a broken socket could sometimes return the error "Connection reset by peer" on the attempt to read or write when the socket was closed. This behavior was not observed on the *nix and Windows CI jobs but it is a valid behavior. Currently the socket is detected as broken when no bytes are returned by the read call.
This PR adds in logic handling the case that when the first write and read operations happen if there was an error then a fresh socket is requested and the write and follow up read is attempted a second time. If the second write and read errors then the error is returned.
It was observed via CI that on Mac OS a broken socket could sometimes return the error "Connection reset by peer" on the attempt to read or write when the socket was closed. This behavior was not observed on the *nix and Windows CI jobs but it is a valid behavior. Currently the socket is detected as broken when no bytes are returned by the
read
call.This PR adds in logic handling the case that when the first write and read operations happen if there was an error then a fresh socket is requested and the write and follow up read is attempted a second time. If the second write and read errors then the error is returned.