From ea3f8ba0b7f085d23aa6f05f0ca418da6524490b Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Sat, 9 Dec 2006 20:28:41 +0000 Subject: added g_tcp_can_send --- common/os_calls.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'common/os_calls.c') 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 @@ -434,6 +434,31 @@ g_tcp_send(int sck, const void* ptr, int len, int flags) #endif } +/*****************************************************************************/ +/* 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) -- cgit v1.2.1