From 8832a6477f868e6d8b315ec89635cee9c4cb17c5 Mon Sep 17 00:00:00 2001 From: David Lin Date: Sun, 12 Apr 2020 10:57:12 +0800 Subject: [PATCH] Update tcp_client.c --- examples/tcp_udp_base_lwip/tcp_client/tcp_client.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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));