← index #7983PR #15223
Related · medium · value 0.082
QUERY · ISSUE

Socket connect timeout - Feature request

openby Tangerinoopened 2021-11-10updated 2021-11-10

My use case is:

MP is connected to a network where can reach the internet (upstream network) and devices in the LAN (downstream network).
Is known that downstream devices are there and sometimes many, I need to reduce the sock.connect(addr) timeout out so this blocking call does not hang the whole system too much.

So an optional timeout parameter (in msec) would be helpful.

Thank you.

CANDIDATE · PULL REQUEST

extmod/modlwip: Make socket.connect raise ETIMEDOUT on non-zero timeout.

mergedby dpgeorgeopened 2024-06-07updated 2024-06-07
extmod

If the socket timeout is 0 then a failed socket.connect() raises EINPROGRESS (which is what the lwIP bindings already did), but if the socket timeout is non-zero then a failed socket.connect() should raise ETIMEDOUT. The latter is fixed in this commit.

A test is added for these timeout cases.

Also, clean up the timeout logic for socket.accept().

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied