Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 1365f7f

Browse files
committed
esp32/modsocket: When resolving IP addr handle the case of host=''.
1 parent 67d141c commit 1365f7f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

esp32/modsocket.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,13 @@ static int _socket_getaddrinfo2(const mp_obj_t host, const mp_obj_t portx, struc
108108
port = mp_obj_str_binary_op(MP_BINARY_OP_MODULO, mp_obj_new_str("%s", 2, true), port);
109109
}
110110

111-
mp_uint_t host_len, port_len;
112-
const char *host_str = mp_obj_str_get_data(host, &host_len);
113-
const char *port_str = mp_obj_str_get_data(port, &port_len);
111+
const char *host_str = mp_obj_str_get_str(host);
112+
const char *port_str = mp_obj_str_get_str(port);
113+
114+
if (host_str[0] == '\0') {
115+
// a host of "" is equivalent to the default/all-local IP address
116+
host_str = "0.0.0.0";
117+
}
114118

115119
MP_THREAD_GIL_EXIT();
116120
int res = lwip_getaddrinfo(host_str, port_str, &hints, resp);

0 commit comments

Comments
 (0)