diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-02-18 23:59:36 +0100 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2011-02-18 23:59:36 +0100 |
commit | 258d52ffb0112f457fa2503493b9f353d08bdf24 (patch) | |
tree | e5351adf2e783ac727c136a67f7cc9aa250e561b /lib/system.c | |
parent | 09e0737359ca51974b427ad12bb5bec4ed031e8b (diff) | |
download | gnutls-258d52ffb0112f457fa2503493b9f353d08bdf24.tar.gz |
Several updates for DTLS (client side only) to work.
Diffstat (limited to 'lib/system.c')
-rw-r--r-- | lib/system.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/system.c b/lib/system.c index f3bed5f7b7..d89c283709 100644 --- a/lib/system.c +++ b/lib/system.c @@ -105,6 +105,22 @@ system_read_peek (gnutls_transport_ptr ptr, void *data, size_t data_size) return recv (GNUTLS_POINTER_TO_INT (ptr), data, data_size, MSG_PEEK); } +/* Wait for data to be received within a timeout period in milliseconds + */ +int system_recv_timeout(gnutls_transport_ptr ptr, size_t ms) +{ +fd_set rfds; +struct timeval tv; + + FD_ZERO(&rfds); + FD_SET(GNUTLS_POINTER_TO_INT(ptr), &rfds); + + tv.tv_sec = 0; + tv.tv_usec = ms * 1000; + + return select(GNUTLS_POINTER_TO_INT(ptr)+1, &rfds, NULL, NULL, &tv); +} + /* Thread stuff */ #ifdef HAVE_WIN32_LOCKS |