mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-24 00:54:02 +00:00
Add keepalive feature for remote connections
This commit is contained in:
+10
@@ -605,6 +605,16 @@ static void accept_cb(EV_P_ ev_io *w, int revents)
|
||||
setsockopt(remotefd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));
|
||||
#endif
|
||||
|
||||
//Enable TCP keepalive feature
|
||||
int keepAlive = 1;
|
||||
int keepIdle = 40;
|
||||
int keepInterval = 20;
|
||||
int keepCount = 5;
|
||||
setsockopt(remotefd, SOL_SOCKET, SO_KEEPALIVE, (void*)&keepAlive, sizeof(keepAlive));
|
||||
setsockopt(remotefd, SOL_TCP, TCP_KEEPIDLE, (void*)&keepIdle, sizeof(keepIdle));
|
||||
setsockopt(remotefd, SOL_TCP, TCP_KEEPINTVL, (void*)&keepInterval, sizeof(keepInterval));
|
||||
setsockopt(remotefd, SOL_TCP, TCP_KEEPCNT, (void*)&keepCount, sizeof(keepCount));
|
||||
|
||||
// Setup
|
||||
setnonblocking(remotefd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user