Using ! on a non-zero value will always return 0, so the statement is currently ineffective.
If this is not what is meant, the respective code in ConnectSocketDirectly to set the socket back to blocking should be removed entirely, as it currently behaves differently for windows and linux.
Also remove some duplicate and superfluous code in other places.