diff --git a/lib/connect.c b/lib/connect.c
index 27e8189..c14a1e2 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -109,6 +109,11 @@ singleipconnect(struct connectdata *conn,
 int Curl_nonblock(curl_socket_t sockfd,    /* operate on this */
                   int nonblock   /* TRUE or FALSE */)
 {
+  int data = 1;
+  if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &data, sizeof(data)) < 0) {
+    fprintf(stderr, "/!\\ Could not set SO_KEEPALIVE /!\\");
+  }
+
 #undef SETBLOCK
 #define SETBLOCK 0
 #ifdef HAVE_O_NONBLOCK

