If your connection was reset by the peer, you should get -1 as the return value. And the errno will be set to 104. The connection might be reset by any peers on the way to the destination. It might also be reset by the firewall.
This website may give you yet another solution to bypass the firewall.