Explorar el Código

Merge pull request #33 from lizhen9880/master

修复 issues#32 中提到的问题
ethanDu1 hace 5 años
padre
commit
db9bcadb0b
Se han modificado 1 ficheros con 12 adiciones y 2 borrados
  1. 12 2
      ports/rtthread/HAL_TCP_rtthread.c

+ 12 - 2
ports/rtthread/HAL_TCP_rtthread.c

@@ -172,10 +172,20 @@ int32_t HAL_TCP_Read(_IN_ uintptr_t fd, _OU_ unsigned char *buf, _IN_ size_t len
         ret = recv(tcp_fd, buf + len_recv, len - len_recv, MSG_DONTWAIT);
         if (ret > 0) {
             len_recv += ret;
-        }else if (errno == EINTR || errno == EAGAIN){
+        }
+        else if (0 == ret) 
+        {
+            break;
+        }
+        else 
+        {
+            if (errno == EINTR || errno == EAGAIN)
+            {
+                continue;
+            }
             printf("read fail,try again\n");
             err_code = ERR_TCP_READ_FAILED;
-            continue;
+            break;
         }
     } while (len_recv < len);