Merge pull request #195 from DavidLin1577/patch-7

Update HAL_UDP_lwip.c
This commit is contained in:
Supowang
2020-06-30 14:54:39 +08:00
committed by GitHub
4 changed files with 16 additions and 16 deletions

View File

@@ -46,7 +46,7 @@ uintptr_t HAL_UDP_Connect(const char *host, unsigned short port)
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_protocol = IPPROTO_UDP; hints.ai_protocol = IPPROTO_UDP;
Log_d("establish tcp connection with server(host=%s port=%s)", host, port_str); Log_d("establish udp connection with server(host=%s port=%s)", host, port_str);
if (getaddrinfo(host, port_str, &hints, &addr_list) != 0) { if (getaddrinfo(host, port_str, &hints, &addr_list) != 0) {
Log_e("getaddrinfo error,errno:%s", strerror(errno)); Log_e("getaddrinfo error,errno:%s", strerror(errno));

View File

@@ -47,7 +47,7 @@ uintptr_t HAL_UDP_Connect(const char *host, unsigned short port)
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_protocol = IPPROTO_UDP; hints.ai_protocol = IPPROTO_UDP;
Log_d("establish tcp connection with server(host=%s port=%s)", host, port_str); Log_d("establish udp connection with server(host=%s port=%s)", host, port_str);
if (getaddrinfo(host, port_str, &hints, &addr_list) != 0) { if (getaddrinfo(host, port_str, &hints, &addr_list) != 0) {
Log_e("getaddrinfo error,errno:%s", strerror(errno)); Log_e("getaddrinfo error,errno:%s", strerror(errno));

View File

@@ -46,7 +46,7 @@ uintptr_t HAL_UDP_Connect(const char *host, unsigned short port)
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_protocol = IPPROTO_UDP; hints.ai_protocol = IPPROTO_UDP;
Log_d("establish tcp connection with server(host=%s port=%s)", host, port_str); Log_d("establish udp connection with server(host=%s port=%s)", host, port_str);
if (getaddrinfo(host, port_str, &hints, &addr_list) != 0) { if (getaddrinfo(host, port_str, &hints, &addr_list) != 0) {
Log_e("getaddrinfo error,errno:%s", strerror(errno)); Log_e("getaddrinfo error,errno:%s", strerror(errno));

View File

@@ -47,27 +47,27 @@ uintptr_t HAL_UDP_Connect(const char *host, unsigned short port)
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
hints.ai_protocol = IPPROTO_UDP; hints.ai_protocol = IPPROTO_UDP;
Log_d("establish tcp connection with server(host=%s port=%s)", host, port_str); Log_d("establish udp connection with server(host=%s port=%s)", host, port_str);
if (getaddrinfo(host, port_str, &hints, &addr_list) != 0) { if (getaddrinfo(host, port_str, &hints, &addr_list) != 0) {
Log_e("getaddrinfo error,errno:%s",strerror(errno)); Log_e("getaddrinfo error,errno:%s",strerror(errno));
return 0; return 0;
} }
for (cur = addr_list; cur != NULL; cur = cur->ai_next) { for (cur = addr_list; cur != NULL; cur = cur->ai_next) {
fd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol); fd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
if (fd < 0) { if (fd < 0) {
ret = 0; ret = 0;
continue; continue;
} }
if (0 == connect(fd, cur->ai_addr, cur->ai_addrlen)) { if (0 == connect(fd, cur->ai_addr, cur->ai_addrlen)) {
ret = fd + LWIP_SOCKET_FD_SHIFT; ret = fd + LWIP_SOCKET_FD_SHIFT;
break; break;
} }
close(fd); close(fd);
ret = 0; ret = 0;
} }
if (0 == ret) { if (0 == ret) {