Implement getaddrinfo in wasi_socket_ext.c (#1413)

So getaddrinfo() can be used when compiling wasm app of C programs.
This commit is contained in:
Marcin Kolny
2022-09-02 15:11:58 +02:00
committed by GitHub
parent 9a04c21075
commit 3c4e980c9c
6 changed files with 246 additions and 2 deletions

View File

@ -256,14 +256,15 @@ os_socket_addr_resolve(const char *host, const char *service,
if (hints_enabled) {
if (hint_is_ipv4) {
hints.ai_family = *hint_is_ipv4 ? PF_INET : PF_INET6;
hints.ai_family = *hint_is_ipv4 ? AF_INET : AF_INET6;
}
if (hint_is_tcp) {
hints.ai_socktype = *hint_is_tcp ? SOCK_STREAM : SOCK_DGRAM;
}
}
ret = getaddrinfo(host, service, hints_enabled ? &hints : NULL, &result);
ret = getaddrinfo(host, strlen(service) == 0 ? NULL : service,
hints_enabled ? &hints : NULL, &result);
if (ret != BHT_OK) {
errno = getaddrinfo_error_to_errno(ret);
return BHT_ERROR;