Free (GPLv2) TCP/IP stack developed by TASS Belgium

Dependents:   lpc1768-picotcp-demo ZeroMQ_PicoTCP_Publisher_demo TCPSocket_HelloWorld_PicoTCP Pico_TCP_UDP_Test ... more

Issue: UDPSocket.recvfrom() returns 0 instead of "Destination unreachable" error (Closed: Fixed)

receivefrom has a blocking behaviour. If the receive buffer is empty it blocks until an UDP packet is received. We discovered a case where a call to receivefrom immediately returned with zero received bytes without waiting for a packet to arrive. This happens with the following sequence. Every packet is send/received from the same socket:

receivefrom()
pico <--- UDP, data="hello" --- we
receivefrom returns with 5 bytes
sendto("hello")
pico --- UDP, data="hello" ---> we
pico <--- ICMP port unreach --- we
receivefrom()
receivefrom returns with 0 bytes
receivefrom()
receivefrom returns with 0 bytes
...

The ICMP port unreach triggers this strange behaviour. If you leave it out, receivefrom behaves normal.

2 comments:

11 Dec 2013

For UDP sockets we should reset the error flag before calling doing the wait. This is easy to fix.

11 Dec 2013

Fixed.