check if the socket has been closed by peer, apply this to all platforms