diff --git a/examples/tcp_udp_base_lwip/tcp_client/tcp_client.c b/examples/tcp_udp_base_lwip/tcp_client/tcp_client.c index 34a762a4..a05f7d23 100644 --- a/examples/tcp_udp_base_lwip/tcp_client/tcp_client.c +++ b/examples/tcp_udp_base_lwip/tcp_client/tcp_client.c @@ -22,8 +22,12 @@ void application_entry(void *arg) MX_LWIP_Init(); - while (1) { - socketfd = socket(AF_INET, SOCK_STREAM, 0); + while (1) { + if ((socketfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + printf("create socket error %s errno: %d\n", strerror(errno), errno); + goto tcp_client_exit; + } + setsockopt(socketfd, SOL_SOCKET, SO_RCVTIMEO, (char*)&tv, sizeof(struct timeval)); memset(&sockaddr, 0, sizeof(sockaddr));