8000 esp32/modsocket: Allow getaddrinfo() to take up to 6 args. · micropython/micropython@cced43f · GitHub
[go: up one dir, main page]

Skip to content

Commit cced43f

Browse files
committed
esp32/modsocket: Allow getaddrinfo() to take up to 6 args.
Currently only the first 2 args are used, but this patch should at least make getaddrinfo() signature-compatible with CPython and other bare-metal ports that use the lwip bindings.
1 parent e600810 commit cced43f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ports/esp32/modsocket.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,11 @@ STATIC mp_obj_t get_socket(size_t n_args, const mp_obj_t *args) {
520520
}
521521
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(get_socket_obj, 0, 3, get_socket);
522522

523-
STATIC mp_obj_t esp_socket_getaddrinfo(const mp_obj_t host, const mp_obj_t port) {
523+
STATIC mp_obj_t esp_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) {
524+
// TODO support additional args beyond the first two
525+
524526
struct addrinfo *res = NULL;
525-
_socket_getaddrinfo2(host, port, &res);
527+
_socket_getaddrinfo2(args[0], args[1], &res);
526528
mp_obj_t ret_list = mp_obj_new_list(0, NULL);
527529

528530
for (struct addrinfo *resi = res; resi; resi = resi->ai_next) {
@@ -552,7 +554,7 @@ STATIC mp_obj_t esp_socket_getaddrinfo(const mp_obj_t host, const mp_obj_t port)
552554
if (res) lwip_freeaddrinfo(res);
553555
return ret_list;
554556
}
555-
STATIC MP_DEFINE_CONST_FUN_OBJ_2(esp_socket_getaddrinfo_obj, esp_socket_getaddrinfo);
557+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_socket_getaddrinfo_obj, 2, 6, esp_socket_getaddrinfo);
556558

557559
STATIC mp_obj_t esp_socket_initialize() {
558560
static int initialized = 0;

0 commit comments

Comments
 (0)
0