Move to milliseconds in recv_timeout()
diff --git a/library/net.c b/library/net.c
index 7336f21..9d02661 100644
--- a/library/net.c
+++ b/library/net.c
@@ -585,10 +585,10 @@
 
 #if defined(POLARSSL_HAVE_TIME)
 /*
- * Read at most 'len' characters, blocking for at most 'timeout' seconds
+ * Read at most 'len' characters, blocking for at most 'timeout' ms
  */
 int net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
-                      unsigned char timeout )
+                      uint32_t timeout )
 {
     int ret;
     struct timeval tv;
@@ -598,8 +598,8 @@
     FD_ZERO( &read_fds );
     FD_SET( fd, &read_fds );
 
-    tv.tv_sec  = timeout;
-    tv.tv_usec = 0;
+    tv.tv_sec  = timeout / 1000;
+    tv.tv_usec = ( timeout % 1000 ) * 1000;
 
     ret = select( fd + 1, &read_fds, NULL, NULL, &tv );
 
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 215f005..34ef165 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -1990,7 +1990,7 @@
             ssl->handshake != NULL ) /* No timeout outside handshake */
         {
             ret = ssl->f_recv_timeout( ssl->p_bio, ssl->in_hdr, len,
-                                   ssl->handshake->retransmit_timeout / 1000 );
+                                       ssl->handshake->retransmit_timeout );
         }
         else
             ret = ssl->f_recv( ssl->p_bio, ssl->in_hdr, len );
@@ -4936,8 +4936,8 @@
         void *p_bio,
         int (*f_send)(void *, const unsigned char *, size_t),
         int (*f_recv)(void *, unsigned char *, size_t),
-        int (*f_recv_timeout)(void *, unsigned char *, size_t, unsigned char),
-        unsigned char timeout )
+        int (*f_recv_timeout)(void *, unsigned char *, size_t, uint32_t),
+        uint32_t timeout )
 {
     ssl->p_bio          = p_bio;
     ssl->f_send         = f_send;