if we read zero bytes from the proxy, the connection is broken and we need
to bail out
diff --git a/lib/socks.c b/lib/socks.c
index 6b95e75..e1ad86c 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -98,6 +98,11 @@
       result = CURLE_OK;
       break;
     }
+    if(!nread) {
+      result = ~CURLE_OK;
+      break;
+    }
+
     buffersize -= nread;
     buf += nread;
     allread += nread;