Enable keepalive on socket connections

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@21310 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-06-15 03:56:13 +00:00
parent 433e72bc8d
commit 131e658ae2
4 changed files with 39 additions and 0 deletions

View file

@ -697,6 +697,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
NSString *lhost = nil;
NSString *shost = nil;
NSString *sport = nil;
int status;
if (beenHere == NO)
{
@ -829,6 +830,12 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
RELEASE(self);
return nil;
}
/*
* Enable tcp-level tracking of whether connection is alive.
*/
status = 1;
setsockopt(net, SOL_SOCKET, SO_KEEPALIVE, (char *)&status, sizeof(status));
if (lhost != nil)
{
if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == SOCKET_ERROR)
@ -2133,6 +2140,14 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
GSFileHandle *h;
struct sockaddr_in sin;
int size = sizeof(sin);
int status;
/*
* Enable tcp-level tracking of whether connection is alive.
*/
status = 1;
setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char *)&status,
sizeof(status));
#if defined(__MINGW__)
h = [[[self class] alloc] initWithNativeHandle: (void*)desc