mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
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:
parent
e4e909b06d
commit
6dc002c448
4 changed files with 39 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2005-06-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSFileHandle.m:
|
||||||
|
* Source/NSSocketPort.m:
|
||||||
|
* Source/NSMessagePort.m:
|
||||||
|
Enable KEEPALIVE on stream sockets, so we will notice if the remote
|
||||||
|
end drops the connection.
|
||||||
|
|
||||||
2005-06-08 Richard Frith-Macdonald <rfm@gnu.org>
|
2005-06-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSCalendardate.m: Fix crash when a nil string is passed to
|
* Source/NSCalendardate.m: Fix crash when a nil string is passed to
|
||||||
|
|
|
@ -697,6 +697,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
||||||
NSString *lhost = nil;
|
NSString *lhost = nil;
|
||||||
NSString *shost = nil;
|
NSString *shost = nil;
|
||||||
NSString *sport = nil;
|
NSString *sport = nil;
|
||||||
|
int status;
|
||||||
|
|
||||||
if (beenHere == NO)
|
if (beenHere == NO)
|
||||||
{
|
{
|
||||||
|
@ -829,6 +830,12 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
||||||
RELEASE(self);
|
RELEASE(self);
|
||||||
return nil;
|
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 (lhost != nil)
|
||||||
{
|
{
|
||||||
if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == SOCKET_ERROR)
|
if (bind(net, (struct sockaddr *)&lsin, sizeof(lsin)) == SOCKET_ERROR)
|
||||||
|
@ -2133,6 +2140,14 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
|
||||||
GSFileHandle *h;
|
GSFileHandle *h;
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
int size = sizeof(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__)
|
#if defined(__MINGW__)
|
||||||
h = [[[self class] alloc] initWithNativeHandle: (void*)desc
|
h = [[[self class] alloc] initWithNativeHandle: (void*)desc
|
||||||
|
|
|
@ -469,6 +469,10 @@ static Class runLoopClass;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int status = 1;
|
||||||
|
|
||||||
|
setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status,
|
||||||
|
sizeof(status));
|
||||||
addrNum = 0;
|
addrNum = 0;
|
||||||
caller = YES;
|
caller = YES;
|
||||||
[aPort addHandle: self forSend: YES];
|
[aPort addHandle: self forSend: YES];
|
||||||
|
@ -1631,6 +1635,10 @@ static int unique_index = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int status = 1;
|
||||||
|
|
||||||
|
setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status,
|
||||||
|
sizeof(status));
|
||||||
/*
|
/*
|
||||||
* Create a handle for the socket and set it up so we are its
|
* Create a handle for the socket and set it up so we are its
|
||||||
* receiving port, and it's waiting to get the port name from
|
* receiving port, and it's waiting to get the port name from
|
||||||
|
|
|
@ -635,6 +635,10 @@ static Class runLoopClass;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int status = 1;
|
||||||
|
|
||||||
|
setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status,
|
||||||
|
sizeof(status));
|
||||||
addrNum = 0;
|
addrNum = 0;
|
||||||
caller = YES;
|
caller = YES;
|
||||||
[aPort addHandle: self forSend: YES];
|
[aPort addHandle: self forSend: YES];
|
||||||
|
@ -2122,6 +2126,10 @@ static unsigned wordAlign;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int status = 1;
|
||||||
|
|
||||||
|
setsockopt(desc, SOL_SOCKET, SO_KEEPALIVE, (char*)&status,
|
||||||
|
sizeof(status));
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
// reset associated event with new socket
|
// reset associated event with new socket
|
||||||
WSAEventSelect(desc, eventListener, 0);
|
WSAEventSelect(desc, eventListener, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue