diff options
| author | norrarvid <norrarvid@gmail.com> | 2012-06-04 10:11:11 +0200 |
|---|---|---|
| committer | norrarvid <norrarvid@gmail.com> | 2012-06-04 10:11:11 +0200 |
| commit | e5fb05e9cba476ec67f71fee1d79ddd5cdd12f2c (patch) | |
| tree | 0363a78110ffbc2ac01d35d722459fd3aff60dbf /common/os_calls.c | |
| parent | 60b052965634be151d88f7011149d0edc71f23d8 (diff) | |
| download | xrdp-proprietary-e5fb05e9cba476ec67f71fee1d79ddd5cdd12f2c.tar.gz xrdp-proprietary-e5fb05e9cba476ec67f71fee1d79ddd5cdd12f2c.zip | |
Support for TCP keepalive and TCP no_delay added
Diffstat (limited to 'common/os_calls.c')
| -rw-r--r-- | common/os_calls.c | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 211adc82..a0a8304c 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -321,9 +321,11 @@ g_getchar(void) } /*****************************************************************************/ +/*Returns 0 on success*/ int APP_CC g_tcp_set_no_delay(int sck) { + int ret = 1 ; /*error*/ #if defined(_WIN32) int option_value; int option_len; @@ -341,11 +343,55 @@ g_tcp_set_no_delay(int sck) { option_value = 1; option_len = sizeof(option_value); - setsockopt(sck, IPPROTO_TCP, TCP_NODELAY, (char*)&option_value, - option_len); + if(setsockopt(sck, IPPROTO_TCP, TCP_NODELAY, (char*)&option_value, + option_len)==0) + { + ret = 0 ; /* success */ + } } } - return 0; + else + { + g_writeln("Error getting tcp_nodelay"); + } + return ret; +} + +/*****************************************************************************/ +/*Returns 0 on success*/ +int APP_CC +g_tcp_set_keepalive(int sck) +{ + int ret = 1 ; /*error*/ +#if defined(_WIN32) + int option_value; + int option_len; +#else + int option_value; + unsigned int option_len; +#endif + + option_len = sizeof(option_value); + /* SOL_TCP IPPROTO_TCP */ + if (getsockopt(sck, SOL_SOCKET, SO_KEEPALIVE, (char*)&option_value, + &option_len) == 0) + { + if (option_value == 0) + { + option_value = 1; + option_len = sizeof(option_value); + if(setsockopt(sck, SOL_SOCKET, SO_KEEPALIVE, (char*)&option_value, + option_len)==0) + { + ret = 0 ; /* success */ + } + } + } + else + { + g_writeln("Error getting tcp_keepalive"); + } + return ret; } /*****************************************************************************/ |
