Problem polling a UDP socket on ESP8266 -- works on ESP32

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
oserror
Posts: 33
Joined: Tue Feb 12, 2019 12:26 am

Problem polling a UDP socket on ESP8266 -- works on ESP32

Post by oserror » Wed Mar 20, 2019 6:11 pm

I am not sure where this post belongs. On the ESP8266, when I try to use select to poll a UDP socket, I am getting POLLHUP? errors:

Code: Select all

>>> import socket, select
>>> sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>>> sock.bind(('0.0.0.0', 2001))
>>> poller = select.poll()
>>> poller.register(sock, select.POLLIN | select.POLLHUP | select.POLLERR)
>>> while True:
...     sleep(1)
...     print('Waiting for event')
...     events = poller.poll(1000)
...     for s, flag in events:
...         print('socket: %s\tflag: %s' % (s, flag))
...         
...         
... 
Waiting for event
socket: <socket state=0 timeout=-1 incoming=0 off=0>	flag: 16
Waiting for event
socket: <socket state=0 timeout=-1 incoming=0 off=0>	flag: 16
Waiting for event
socket: <socket state=0 timeout=-1 incoming=0 off=0>	flag: 16
Waiting for event
socket: <socket state=0 timeout=-1 incoming=0 off=0>	flag: 16
On the ESP32, things are normal:

Code: Select all

=== import socket, select
=== sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
=== sock.bind(('0.0.0.0', 2001))
=== poller = select.poll()
=== poller.register(sock, select.POLLIN | select.POLLHUP | select.POLLERR)
=== while True:
===     sleep(1)
===     print('Waiting for event')
===     events = poller.poll(1000)
===     for s, flag in events:
===         print('socket: %s\tflag: %s' % (s, flag))

Waiting for event
Waiting for event
Waiting for event
Waiting for event
Waiting for event
Waiting for event
Waiting for event
Is there something missing here that I should be doing? I have changed port numbers and there should not be any traffic at all directed towards the device. TCP sockets work fine on both machines.

Thanks for any help!

Post Reply