Skip to content

Commit be70c23

Browse files
committed
Allow resolution of hostname "localhost"
Signed-off-by: Dan Kouba <dan@atym.io>
1 parent e1bcab4 commit be70c23

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

core/shared/platform/zephyr/zephyr_socket.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,16 @@ os_socket_addr_resolve(const char *host, const char *service,
442442
}
443443
}
444444

445-
ret = zsock_getaddrinfo(host, strlen(service) == 0 ? NULL : service,
445+
char *_host;
446+
if (!strcmp(host, "localhost")) {
447+
printk("os_socket_addr_resolve called with host=\"localhost\" - "
448+
"substituting 127.0.0.1\n");
449+
_host = "127.0.0.1";
450+
} else {
451+
_host = (char *)host;
452+
}
453+
454+
ret = zsock_getaddrinfo(_host, strlen(service) == 0 ? NULL : service,
446455
hints_enabled ? &hints : NULL, &result);
447456
if (ret != BHT_OK) {
448457
errno = getaddrinfo_error_to_errno(ret);

0 commit comments

Comments
 (0)