Skip to content

Commit fda874e

Browse files
committed
extmod/modlwip: Support non-blocking recv().
1 parent 7379be3 commit fda874e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

extmod/modlwip.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@ STATIC mp_uint_t lwip_tcp_send(lwip_socket_obj_t *socket, const byte *buf, mp_ui
385385
// Helper function for recv/recvfrom to handle TCP packets
386386
STATIC mp_uint_t lwip_tcp_receive(lwip_socket_obj_t *socket, byte *buf, mp_uint_t len, int *_errno) {
387387
if (socket->incoming.pbuf == NULL) {
388+
389+
// Non-blocking socket
390+
if (socket->timeout == 0) {
391+
*_errno = EAGAIN;
392+
return -1;
393+
}
394+
388395
mp_uint_t start = mp_hal_ticks_ms();
389396
while (socket->state == STATE_CONNECTED && socket->incoming.pbuf == NULL) {
390397
if (socket->timeout != -1 && mp_hal_ticks_ms() - start > socket->timeout) {

0 commit comments

Comments
 (0)