libfreerdp-core: set SO_KEEPALIVE socket option
This commit is contained in:
parent
aec2b492e4
commit
9d1f13e82e
@ -167,6 +167,8 @@ boolean tcp_connect(rdpTcp* tcp, const char* hostname, uint16 port)
|
||||
}
|
||||
}
|
||||
|
||||
tcp_set_keep_alive_mode(tcp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -258,6 +260,34 @@ boolean tcp_set_blocking_mode(rdpTcp* tcp, boolean blocking)
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean tcp_set_keep_alive_mode(rdpTcp* tcp)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
uint32 option_value;
|
||||
socklen_t option_len;
|
||||
|
||||
option_value = 1;
|
||||
option_len = sizeof(option_value);
|
||||
|
||||
if (setsockopt(tcp->sockfd, SOL_SOCKET, SO_KEEPALIVE, (void*) &option_value, option_len) < 0)
|
||||
{
|
||||
perror("setsockopt() SOL_SOCKET, SO_KEEPALIVE:");
|
||||
return false;
|
||||
}
|
||||
|
||||
option_value = 5;
|
||||
option_len = sizeof(option_value);
|
||||
|
||||
if (setsockopt(tcp->sockfd, SOL_TCP, TCP_KEEPIDLE, (void*) &option_value, option_len) < 0)
|
||||
{
|
||||
perror("setsockopt() SOL_TCP, SO_KEEPIDLE:");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
rdpTcp* tcp_new(rdpSettings* settings)
|
||||
{
|
||||
rdpTcp* tcp;
|
||||
|
@ -53,6 +53,7 @@ boolean tcp_disconnect(rdpTcp* tcp);
|
||||
int tcp_read(rdpTcp* tcp, uint8* data, int length);
|
||||
int tcp_write(rdpTcp* tcp, uint8* data, int length);
|
||||
boolean tcp_set_blocking_mode(rdpTcp* tcp, boolean blocking);
|
||||
boolean tcp_set_keep_alive_mode(rdpTcp* tcp);
|
||||
|
||||
rdpTcp* tcp_new(rdpSettings* settings);
|
||||
void tcp_free(rdpTcp* tcp);
|
||||
|
Loading…
Reference in New Issue
Block a user