Index: lwip/src/api/api_lib.c
===================================================================
RCS file: /sources/lwip/lwip/src/api/api_lib.c,v
retrieving revision 1.27
diff -u -u -r1.27 api_lib.c
--- lwip/src/api/api_lib.c	6 Mar 2007 16:41:02 -0000	1.27
+++ lwip/src/api/api_lib.c	6 Mar 2007 19:55:04 -0000
@@ -234,7 +234,7 @@
   msg.msg.msg.bc.port = proto; /* misusing the port field */
   msg.msg.conn = conn;
   api_msg_post(&msg);  
-  sys_mbox_fetch(conn->mbox, NULL, 0);
+  sys_mbox_fetch(conn->mbox, NULL);
 
   if ( conn->err != ERR_OK ) {
     memp_free(MEMP_NETCONN, conn);
@@ -272,7 +272,7 @@
   msg.type = API_MSG_DELCONN;
   msg.msg.conn = conn;
   api_msg_post(&msg);  
-  sys_mbox_fetch(conn->mbox, NULL, 0);
+  sys_mbox_fetch(conn->mbox, NULL);
 
   /* Drain the recvmbox. */
   if (conn->recvmbox != SYS_MBOX_NULL) {
@@ -387,7 +387,7 @@
   msg.msg.msg.bc.ipaddr = addr;
   msg.msg.msg.bc.port = port;
   api_msg_post(&msg);
-  sys_mbox_fetch(conn->mbox, NULL, 0);
+  sys_mbox_fetch(conn->mbox, NULL);
   return conn->err;
 }
 
@@ -414,7 +414,7 @@
   msg.msg.msg.bc.ipaddr = addr;
   msg.msg.msg.bc.port = port;
   api_msg_post(&msg);
-  sys_mbox_fetch(conn->mbox, NULL, 0);
+  sys_mbox_fetch(conn->mbox, NULL);
   return conn->err;
 }
 
@@ -430,7 +430,7 @@
   msg.type = API_MSG_DISCONNECT;
   msg.msg.conn = conn;  
   api_msg_post(&msg);
-  sys_mbox_fetch(conn->mbox, NULL, 0);
+  sys_mbox_fetch(conn->mbox, NULL);
   return conn->err;
 
 }
@@ -454,7 +454,7 @@
   msg.type = API_MSG_LISTEN;
   msg.msg.conn = conn;
   api_msg_post(&msg);
-  sys_mbox_fetch(conn->mbox, NULL, 0);
+  sys_mbox_fetch(conn->mbox, NULL);
   return conn->err;
 }
 
@@ -467,7 +467,7 @@
     return NULL;
   }
   
-  sys_mbox_fetch(conn->acceptmbox, (void *)&newconn, 0);
+  sys_mbox_fetch(conn->acceptmbox, (void *)&newconn);
   /* Register event with callback */
   if (conn->callback)
       (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, 0);
@@ -475,6 +475,13 @@
   return newconn;
 }
 
+static void
+recv_timeout_handler(void *arg)
+{
+  sys_mbox_t& mbox = (sys_mbox_t*)arg;
+  sys_mbox_post(*mbox, NULL);
+}
+
 struct netbuf *
 netconn_recv(struct netconn *conn)
 {
@@ -510,7 +517,7 @@
       return NULL;
     }
     
-    sys_mbox_fetch(conn->recvmbox, (void *)&p, 0);
+    sys_mbox_fetch(conn->recvmbox, (void *)&p);
 
     if (p != NULL)
     {
@@ -548,11 +555,15 @@
     }
     api_msg_post(&msg);
 
-    sys_mbox_fetch(conn->mbox, NULL, 0);
+    sys_mbox_fetch(conn->mbox, NULL);
   } else {
+    if (conn->recv_timeout)
+      sys_timeout(conn->recv_timeout, recv_timeout_handler, &conn->recvmbox);
     sys_mbox_fetch(conn->recvmbox, (void *)&buf, conn->recv_timeout);
-    if (buf!=NULL)
-     { conn->recv_avail -= buf->p->tot_len;
+    if (buf!=NULL) {
+       if (conn->recv_timeout)
+         sys_untimeout(recv_timeout_handler, conn->recvmbox);
+       conn->recv_avail -= buf->p->tot_len;
        /* Register event with callback */
        if (conn->callback)
            (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, buf->p->tot_len);
@@ -587,7 +598,7 @@
   msg.msg.msg.p = buf->p;
   api_msg_post(&msg);
 
-  sys_mbox_fetch(conn->mbox, NULL, 0);
+  sys_mbox_fetch(conn->mbox, NULL);
   return conn->err;
 }
 
@@ -635,7 +646,7 @@
     LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_write: writing %d bytes (%d)\n", len, copy));
     msg.msg.msg.w.len = len;
     api_msg_post(&msg);
-    sys_mbox_fetch(conn->mbox, NULL, 0);
+    sys_mbox_fetch(conn->mbox, NULL);
     if (conn->err == ERR_OK) {
       dataptr = (void *)((u8_t *)dataptr + len);
       size -= len;
@@ -666,7 +677,7 @@
   msg.type = API_MSG_CLOSE;
   msg.msg.conn = conn;
   api_msg_post(&msg);
-  sys_mbox_fetch(conn->mbox, NULL, 0);
+  sys_mbox_fetch(conn->mbox, NULL);
   if (conn->err == ERR_MEM &&
      conn->sem != SYS_SEM_NULL) {
     sys_sem_wait(conn->sem);
Index: lwip/src/api/tcpip.c
===================================================================
RCS file: /sources/lwip/lwip/src/api/tcpip.c,v
retrieving revision 1.23
diff -u -u -r1.23 tcpip.c
--- lwip/src/api/tcpip.c	6 Mar 2007 19:31:49 -0000	1.23
+++ lwip/src/api/tcpip.c	6 Mar 2007 19:55:04 -0000
@@ -152,7 +152,7 @@
   }
 
   while (1) {                          /* MAIN Loop */
-    sys_mbox_fetch(mbox, (void *)&msg, 0);
+    sys_mbox_fetch(mbox, (void *)&msg);
     switch (msg->type) {
     case TCPIP_MSG_API:
       LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg));
Index: lwip/src/core/sys.c
===================================================================
RCS file: /sources/lwip/lwip/src/core/sys.c,v
retrieving revision 1.21
diff -u -u -r1.21 sys.c
--- lwip/src/core/sys.c	6 Mar 2007 16:41:02 -0000	1.21
+++ lwip/src/core/sys.c	6 Mar 2007 19:55:04 -0000
@@ -46,7 +46,7 @@
 
 
 void
-sys_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
+sys_mbox_fetch(sys_mbox_t mbox, void **msg)
 {
   u32_t time;
   struct sys_timeouts *timeouts;
@@ -59,7 +59,7 @@
   timeouts = sys_arch_timeouts();
 
   if (!timeouts || !timeouts->next) {
-    sys_arch_mbox_fetch(mbox, msg, timeout);
+    sys_arch_mbox_fetch(mbox, msg, 0);
   } else {
     if (timeouts->next->time > 0) {
       time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time);
Index: lwip/src/include/lwip/sys.h
===================================================================
RCS file: /sources/lwip/lwip/src/include/lwip/sys.h,v
retrieving revision 1.20
diff -u -u -r1.20 sys.h
--- lwip/src/include/lwip/sys.h	6 Mar 2007 16:41:02 -0000	1.20
+++ lwip/src/include/lwip/sys.h	6 Mar 2007 19:55:04 -0000
@@ -53,7 +53,7 @@
 #define sys_sem_wait(s)
 #define sys_sem_free(s)
 #define sys_mbox_new() 0
-#define sys_mbox_fetch(m,d,t)
+#define sys_mbox_fetch(m,d)
 #define sys_mbox_post(m,d)
 #define sys_mbox_free(m)
 
@@ -116,7 +116,7 @@
 void sys_mbox_post(sys_mbox_t mbox, void *msg);
 u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);
 void sys_mbox_free(sys_mbox_t mbox);
-void sys_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);
+void sys_mbox_fetch(sys_mbox_t mbox, void **msg);
 
 
 /* Thread functions. */
