Fix socket-api byte order issue when host/network order are the same (#1327)

Fix socket-api byte order issue for systems where host byte order
and network byte order are the same:
- Document data structures used for storing IP addresses
- Fix bug in bind and connect methods by updating code in wasi_socket_ext
This commit is contained in:
Marcin Kolny
2022-07-29 04:26:06 +02:00
committed by GitHub
parent f6bbeade2a
commit 08fd714551
3 changed files with 30 additions and 14 deletions

View File

@ -60,9 +60,7 @@ os_socket_bind(bh_socket_t socket, const char *host, int *port)
goto fail;
}
addr.sin_addr.s_addr = inet_addr(host);
addr.sin_port = htons(*port);
addr.sin_family = AF_INET;
textual_addr_to_sockaddr(host, *port, &addr);
ret = bind(socket, (struct sockaddr *)&addr, sizeof(addr));
if (ret < 0) {