mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 13:10:21 +01:00
extmod/modlwip: Fix error return for TCP recv when not connected.
This commit fixes the cases when a TCP socket is in STATE_NEW, STATE_LISTENING or STATE_CONNECTING and recv() is called on it. It now raises ENOTCONN instead of a random error code due to it previously indexing beyond the start of error_lookup_table[]. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
17
tests/extmod/usocket_tcp_basic.py
Normal file
17
tests/extmod/usocket_tcp_basic.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Test basic, stand-alone TCP socket functionality
|
||||
|
||||
try:
|
||||
import usocket as socket, uerrno as errno
|
||||
except ImportError:
|
||||
try:
|
||||
import socket, errno
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
# recv() on a fresh socket should raise ENOTCONN
|
||||
s = socket.socket()
|
||||
try:
|
||||
s.recv(1)
|
||||
except OSError as er:
|
||||
print("ENOTCONN:", er.args[0] == errno.ENOTCONN)
|
||||
Reference in New Issue
Block a user