cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: TCP_NODELAY

From: Seshubabu Pasam <pasam_at_seshubabu.com>
Date: Thu, 25 Mar 2004 19:28:22 -0800

Here is the patch to set the KEEPALIVE on the socket. This should avoid
sockets from timing out inside applications that hold curl handles for
more than 2 hrs.

Regards
-Seshubabu Pasam

Seshubabu Pasam wrote:
>
> While we are at this, can we also set SO_KEEPALIVE to be ON?
> I don't think this needs to be configurable!
>
> Thanks
> Seshubabu Pasam
>
> Daniel Stenberg wrote:
>
>> On Wed, 24 Mar 2004, Joe Halpin wrote:
>>
>>
>>>>> 3. errno is not set on windows for network related stuff as one would
>>
>>
>>
>>> You can #ifdef the error message out for Windows if you want, or let
>>> me know
>>> and I'll submit another patch. I'm going to bed right now as I'm clearly
>>> being overcome by pollen at this point.
>>
>>
>>
>> It's OK, I'll convert the code over to use our new and shiny
>> Curl_strerror()
>> function.
>>
>

--- connect.c.bak 2004-03-25 19:20:08.000000000 -0800
+++ connect.c 2004-03-25 19:22:51.000000000 -0800
@@ -591,6 +591,7 @@
   for(rc=-1, aliasindex=0;
       rc && (struct in_addr *)remotehost->addr->h_addr_list[aliasindex];
       aliasindex++) {
+ int on = 1;
     struct sockaddr_in serv_addr;
 
     /* create an IPv4 TCP socket */
@@ -619,6 +620,7 @@
 
     /* set socket non-blocking */
     Curl_nonblock(sockfd, TRUE);
+ setsockopt( sockfd, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof(on) );
 
     /* do not use #ifdef within the function arguments below, as connect() is
        a defined macro on some platforms and some compilers don't like to mix
Received on 2004-03-26