added g_tcp_can_send

ulab-original
jsorg71 18 years ago
parent b295e08ad2
commit ea3f8ba0b7

@ -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)

Loading…
Cancel
Save