Hello list.
I have patched MicroPython [1] with LwIP support on Windows. And running some tcp/ip related test shows a funny behaviour in LwIP. E.g. from: https://github.com/micropython/micropython/blob/master/tests/extmod/usocket_tcp_basic.py # 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) The trace in LwIP shows: src/api/sockets.c(1754): lwip_socket(PF_INET, SOCK_STREAM, 0) = 0 src/api/sockets.c(1243): lwip_recvfrom(0, 0E88A030, 1, 0x0, ..) src/api/sockets.c(976): lwip_recv_tcp: top while sock->lastdata=00000000 Now the MicroPython test hangs forever. Nothing happens with this socket 0. It's unconnected, so how could this socket ever receive a single byte? Using the same .py-test in the real CPython 3.6, it immediately returns the expected: py -3 extmod\usocket_tcp_basic.py ENOTCONN: True Could it be some of my 'LWIP_x' options are messed up? [1] https://github.com/micropython/micropython _______________________________________________ lwip-devel mailing list [hidden email] https://lists.nongnu.org/mailman/listinfo/lwip-devel |
Am 24.09.2020 um 18:05 schrieb Gisle Vanem:
> Hello list. > > I have patched MicroPython [1] with LwIP support on Windows. > And running some tcp/ip related test shows a funny > behaviour in LwIP. E.g. from: > https://github.com/micropython/micropython/blob/master/tests/extmod/usocket_tcp_basic.py > > # 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) > > The trace in LwIP shows: > src/api/sockets.c(1754): lwip_socket(PF_INET, SOCK_STREAM, 0) = 0 > src/api/sockets.c(1243): lwip_recvfrom(0, 0E88A030, 1, 0x0, ..) > src/api/sockets.c(976): lwip_recv_tcp: top while sock->lastdata=00000000 > > Now the MicroPython test hangs forever. Nothing happens > with this socket 0. It's unconnected, so how could this socket > ever receive a single byte? It should indeed not wait here, but return an error. Would you mind adding a bug in our savannah bugtracker to ensure this does not get forgotten? > > Using the same .py-test in the real CPython 3.6, it immediately > returns the expected: > py -3 extmod\usocket_tcp_basic.py > ENOTCONN: True > > Could it be some of my 'LWIP_x' options are messed up? Hmm, while this could change with options, it still should not behave like you saw. Regards, Simon > > [1] https://github.com/micropython/micropython _______________________________________________ lwip-devel mailing list [hidden email] https://lists.nongnu.org/mailman/listinfo/lwip-devel |
[hidden email] wrote:
>> Now the MicroPython test hangs forever. Nothing happens >> with this socket 0. It's unconnected, so how could this socket >> ever receive a single byte? > > It should indeed not wait here, but return an error. Would you mind > adding a bug in our savannah bugtracker to ensure this does not get > forgotten? Done at: https://savannah.nongnu.org/bugs/index.php?59182 >> Could it be some of my 'LWIP_x' options are messed up? > > Hmm, while this could change with options, it still should not behave > like you saw. Adding a: #define LWIP_SOCKET_OFFSET 100 for a socket fd to start at 100, did not help. But it looks better than a socket 0. IMHO lwip_socket() returning 0 is highly confusing. -- --gv _______________________________________________ lwip-devel mailing list [hidden email] https://lists.nongnu.org/mailman/listinfo/lwip-devel |
Am 26.09.2020 um 09:54 schrieb Gisle Vanem:
> [hidden email] wrote: > >>> Now the MicroPython test hangs forever. Nothing happens >>> with this socket 0. It's unconnected, so how could this socket >>> ever receive a single byte? >> >> It should indeed not wait here, but return an error. Would you mind >> adding a bug in our savannah bugtracker to ensure this does not get >> forgotten? > > Done at: > https://savannah.nongnu.org/bugs/index.php?59182 > >>> Could it be some of my 'LWIP_x' options are messed up? >> >> Hmm, while this could change with options, it still should not behave >> like you saw. > Adding a: > #define LWIP_SOCKET_OFFSET 100 > > for a socket fd to start at 100, did not help. > But it looks better than a socket 0. IMHO lwip_socket() > returning 0 is highly confusing. Why? File descriptors are >= 0. That's what the spec says: https://pubs.opengroup.org/onlinepubs/009695399/functions/socket.html Regards, Simon _______________________________________________ lwip-devel mailing list [hidden email] https://lists.nongnu.org/mailman/listinfo/lwip-devel |
Free forum by Nabble | Edit this page |