char *host = NULL;
int fd = SOCKET_ERROR;
int ok = 0;
+ int on = 1; /* Value variable for setsockopt() */
shost = gethostbyname(server);
if (!shost)
if (fd < 0)
goto cleanup;
+ if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof(int)) < 0)
+ goto cleanup;
+
if (connect(fd, (struct sockaddr *)&target, sizeof(target)) < 0)
goto cleanup;