I have an application that uses UDP sockets. It runs but I have a problem catching `timeout` exceptions. This code:
Code: Select all
from machine import UART
import socket
uart = UART(0, 115200)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(2.0)
s.bind(("", 9999))
try:
s.receive(10)
except socket.timeout:
uart.write("Exception caught\n")
Code: Select all
Traceback (most recent call last):
File "main.py", line 12, in <module>
AttributeError: type object 'socket' has no attribute 'timeout'
Am I doing something wrong?