if (errno == 104)

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.

Distributed Anti-Interference Proxy Protocol

Source Code: https://github.com/mc256/Distributed_Proxy_System
Source Code (backup): https://git.errno104.com/mc256/Distributed_Proxy_System

For more details, Please see this page.