← index #2490Issue #2947
Related · high · value 2.947
QUERY · ISSUE

esp8266: socket accept() does not always accept

openby MarkR42opened 2016-10-07updated 2018-12-01
port-esp8266

If there is a queue of sockets to accept, accept() does not always clear it, some sockets seem to get "lost", they are still open but accept() will not accept them, it just blocks.


Steps to reproduce

I'm attaching two programs - main.py and client.py. Run client.py on a connected system, under normal python3. Run main.py on an esp8266. Supply the address of the esp8266 as a command line parameter.


Expected results

Despite the sleep(0.25), the sockets should queued and be accepted eventually.

Output should be, for example:

Socks connected: 4
b'Accept 0'
b'Accept 1'
b'Accept 2'
b'Accept 3'

And running the program >1 time should also succeed.

Actual results:

Socks connected: 4
b'Accept 0'
b'Accept 1'
b''
b''

CANDIDATE · ISSUE

esp8266: in non-blocking mode, socket.accept raises ETIMEDOUT instead of EAGAIN

closedby dpgeorgeopened 2017-03-10updated 2017-06-21
bug

Test code:

import socket
s = socket.socket()
s.bind(socket.getaddrinfo("0.0.0.0", 8000)[0][-1])
s.setblocking(False)
s.listen(1)
s.accept()

On CPy and uPy unix the accept raises EAGAIN. On esp8266 it raises ETIMEDOUT.

Note that if the socket is in a blocking mode with a finite timeout (eg s.settimeout(1)) then ETIMEDOUT is the correct error code to raise (matches CPy's socket.timeout exception for this case).

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