summaryrefslogtreecommitdiffstats
path: root/common/os_calls.c
diff options
context:
space:
mode:
authorArvidNorr <norrarvid@gmail.com>2012-06-18 00:00:05 -0700
committerArvidNorr <norrarvid@gmail.com>2012-06-18 00:00:05 -0700
commitd2903cd1fc2f02fd08ea0b55117a3a03e7131504 (patch)
tree0996897428c35bf52ed179c818e33b1406cd76b5 /common/os_calls.c
parent2509442b361b93578431697a083a2ed186e25146 (diff)
parente5fb05e9cba476ec67f71fee1d79ddd5cdd12f2c (diff)
downloadxrdp-proprietary-d2903cd1fc2f02fd08ea0b55117a3a03e7131504.tar.gz
xrdp-proprietary-d2903cd1fc2f02fd08ea0b55117a3a03e7131504.zip
Merge pull request #28 from ArvidNorr/tcp_nodelay
Support for TCP keepalive and TCP no_delay added
Diffstat (limited to 'common/os_calls.c')
-rw-r--r--common/os_calls.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/common/os_calls.c b/common/os_calls.c
index c713bfaa..8b3e01dc 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -325,9 +325,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;
@@ -345,11 +347,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;
}
/*****************************************************************************/