未验证 提交 61a88b49 编写于 作者: S Supowang 提交者: GitHub

Merge pull request #195 from DavidLin1577/patch-7

Update HAL_UDP_lwip.c
......@@ -46,7 +46,7 @@ uintptr_t HAL_UDP_Connect(const char *host, unsigned short port)
hints.ai_family = AF_INET;
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) {
Log_e("getaddrinfo error,errno:%s", strerror(errno));
......
......@@ -47,7 +47,7 @@ uintptr_t HAL_UDP_Connect(const char *host, unsigned short port)
hints.ai_family = AF_INET;
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) {
Log_e("getaddrinfo error,errno:%s", strerror(errno));
......
......@@ -46,7 +46,7 @@ uintptr_t HAL_UDP_Connect(const char *host, unsigned short port)
hints.ai_family = AF_INET;
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) {
Log_e("getaddrinfo error,errno:%s", strerror(errno));
......
......@@ -47,27 +47,27 @@ uintptr_t HAL_UDP_Connect(const char *host, unsigned short port)
hints.ai_family = AF_INET;
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) {
Log_e("getaddrinfo error,errno:%s",strerror(errno));
Log_e("getaddrinfo error,errno:%s",strerror(errno));
return 0;
}
for (cur = addr_list; cur != NULL; cur = cur->ai_next) {
fd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
if (fd < 0) {
ret = 0;
continue;
}
if (0 == connect(fd, cur->ai_addr, cur->ai_addrlen)) {
ret = fd + LWIP_SOCKET_FD_SHIFT;
break;
}
close(fd);
ret = 0;
fd = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
if (fd < 0) {
ret = 0;
continue;
}
if (0 == connect(fd, cur->ai_addr, cur->ai_addrlen)) {
ret = fd + LWIP_SOCKET_FD_SHIFT;
break;
}
close(fd);
ret = 0;
}
if (0 == ret) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册