Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ addToLibrary({
if (family === {{{ cDefs.AF_INET }}}) {
addr = _htonl({{{ cDefs.INADDR_LOOPBACK }}});
} else {
addr = [0, 0, 0, 1];
addr = [0, 0, 0, _htonl(1)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure I follow, this is an ipv6 address, and line 1074 is ipv4? (hence it is valid for one line to return an int, and other a JS array of 4 ints?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ip4 address are presented as a single number, ip6 is an array of 4 numbers.

This changes makes the address report correctly as ::1.

}
}
ai = allocaddrinfo(family, type, proto, null, addr, port);
Expand Down
3 changes: 0 additions & 3 deletions test/sockets/test_getaddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ int main() {
print_addrinfo(servinfo);
assert(servinfo->ai_family == AF_INET6);
assert(servinfo->ai_socktype == SOCK_STREAM);
#ifndef __EMSCRIPTEN__
// TODO(sbc): This assert currently fails under emscripten, but should not
assert(memcmp(&sa6->sin6_addr, &in6addr_loopback, sizeof(in6addr_loopback)) == 0);
#endif
assert(sa6->sin6_port == ntohs(81));
freeaddrinfo(servinfo);

Expand Down
Loading