Index: trunk/src/VBox/Devices/Network/slirp/socket.c
===================================================================
--- trunk/src/VBox/Devices/Network/slirp/socket.c	(revision 23240)
+++ trunk/src/VBox/Devices/Network/slirp/socket.c	(revision 23241)
@@ -542,4 +542,5 @@
 sorecvfrom(PNATState pData, struct socket *so)
 {
+    ssize_t ret = 0;
     struct sockaddr_in addr;
     socklen_t addrlen = sizeof(struct sockaddr_in);
@@ -568,5 +569,5 @@
         int size;
 #endif
-	int rc = 0;
+	    int rc = 0;
         static int signaled = 0;
 
@@ -592,9 +593,19 @@
         {
             rc = ioctlsocket(so->s, FIONREAD, &n);
-            
+            if (   (rc == -1)
+                && (errno == EAGAIN
+                   || errno == EWOULDBLOCK
+                   || errno == EINPROGRESS
+                   || errno == ENOTCONN))
+            {
+                m_free(pData, m);
+                return;
+            }
             if (rc == -1 && signaled == 0)
             {
                 LogRel(("NAT: can't fetch amount of bytes on socket %R[natsock], so message will be truncated.\n", so));
                 signaled = 1;
+                m_free(pData, m);
+                return;
             } 
 
@@ -606,5 +617,5 @@
             }
         }
-        m->m_len = recvfrom(so->s, m->m_data, len, 0,
+        ret = recvfrom(so->s, m->m_data, len, 0,
                             (struct sockaddr *)&addr, &addrlen);
         Log2((" did recvfrom %d, errno = %d-%s\n",
@@ -652,10 +663,10 @@
         m->m_pkthdr.header = mtod(m, void *);
         m->m_data += sizeof(struct udpiphdr); 
-        len = recvfrom(so->s, mtod(m, char *), n, 0,
+        ret = recvfrom(so->s, mtod(m, char *), n, 0,
                             (struct sockaddr *)&addr, &addrlen);
-        m->m_len = len;
         /* @todo (r=vvl) check which flags and type should be passed */
 #endif
-        if(len < 0)
+        m->m_len = ret;
+        if(ret < 0)
         {
             u_char code = ICMP_UNREACH_PORT;
@@ -666,8 +677,16 @@
                 code = ICMP_UNREACH_NET;
 
-            Log2((dfd," rx error, tx icmp ICMP_UNREACH:%i\n", code));
+            m_free(pData, m);
+            if (   errno == EAGAIN
+                || errno == EWOULDBLOCK
+                || errno == EINPROGRESS
+                || errno == ENOTCONN)
+            {
+                return;
+            }
+
+            Log2((" rx error, tx icmp ICMP_UNREACH:%i\n", code));
             icmp_error(pData, so->so_m, ICMP_UNREACH, code, 0, strerror(errno));
             so->so_m = NULL;
-            m_free(pData, m);
         }
         else
@@ -1253,8 +1272,18 @@
     static int signalled = 0;
     rc = ioctlsocket(so->s, FIONREAD, &len);
-    if (rc != -1 && signalled == 0)
+    if (   rc == -1 
+        && (errno == EAGAIN
+        || errno == EWOULDBLOCK
+        || errno == EINPROGRESS
+        || errno == ENOTCONN))
+    {
+        return;
+    }
+    if (rc == -1 && signalled == 0)
     {
         signalled = 1;
-        LogRel(("NAT: fetching number of bits has been failed for ICMP socket \n"));
+        LogRel(("NAT: fetching number of bits has been failed for ICMP socket (%d: %s)\n",
+            errno, strerror(errno)));
+        return;
     }
     len = (len != 0 && rc != -1 ? len : 1500);
@@ -1266,5 +1295,14 @@
     if (len == -1 || len == 0)
     {
-        u_char code = ICMP_UNREACH_PORT;
+        u_char code;
+        if (   len == -1 
+            && (errno == EAGAIN
+            || errno == EWOULDBLOCK
+            || errno == EINPROGRESS
+            || errno == ENOTCONN))
+        {
+            return;
+        }
+        code = ICMP_UNREACH_PORT;
 
         if (errno == EHOSTUNREACH)
@@ -1273,5 +1311,5 @@
             code = ICMP_UNREACH_NET;
 
-        DEBUG_MISC((dfd," udp icmp rx errno = %d-%s\n",
+        LogRel((" udp icmp rx errno = %d-%s\n",
                     errno, strerror(errno)));
         icmp_error(pData, so->so_m, ICMP_UNREACH, code, 0, strerror(errno));
