diff options
Diffstat (limited to 'common/os_calls.c')
-rw-r--r-- | common/os_calls.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index ebdf5491..c48fe99e 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -435,6 +435,31 @@ g_tcp_send(int sck, const void* ptr, int len, int flags) } /*****************************************************************************/ +/* wait 'millis' milliseconds for the socket to be able to write */ +/* returns boolean */ +int +g_tcp_can_send(int sck, int millis) +{ + fd_set wfds; + struct timeval time; + int rv; + + time.tv_sec = millis / 1000; + time.tv_usec = (millis * 1000) % 1000000; + FD_ZERO(&wfds); + if (sck > 0) + { + FD_SET(((unsigned int)sck), &wfds); + rv = select(sck + 1, 0, &wfds, 0, &time); + if (rv > 0) + { + return 1; + } + } + return 0; +} + +/*****************************************************************************/ int g_tcp_select(int sck1, int sck2) { |