From 7b4147dd0b9df469bbae642b3aa02dd74a853685 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Thu, 12 May 2022 12:58:45 +0200 Subject: [PATCH] extmod/modusocket: Fix polling of a new socket. New sockets should return HUP and WR when polled, following modlwip. --- extmod/modusocket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extmod/modusocket.c b/extmod/modusocket.c index 5f07d4f789..9b1eb8cd7a 100644 --- a/extmod/modusocket.c +++ b/extmod/modusocket.c @@ -451,7 +451,8 @@ mp_uint_t socket_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int * } if (self->nic == MP_OBJ_NULL) { if (request == MP_STREAM_POLL) { - return MP_STREAM_POLL_NVAL; + // New sockets are writable and not connected. + return MP_STREAM_POLL_HUP | MP_STREAM_POLL_WR; } *errcode = MP_EINVAL; return MP_STREAM_ERROR;