Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

possible missmatch between rcvevent and pbuf

Hi everybody,

I am using lwip with uc/os ii and the socket api to establish an udp connection. During program execution it might happen, that the pbuf fills up. Trying to empty it, I have recognized that recvfrom() blocks even though I am using the flag MSG_DONTWAIT. Using select() to see if data is pending or lwip_ioctl() to check how many bytes are available will not work.

My only explanation for this behavior would be that even though no more data can be stored in pbuf, rcvevent and recv_avail are incremented, and therefore recvfrom(), select and lwip_ioctl() are awaiting pbuf to hold mor data than there is available.

Any ideas for a work around?

--wolf

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    found out that this problem only occurs if the number of pbuffer is greater than 10.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi pfab,

    you should also use pbuf_free(nameOfPbuf); else you run out of pbufs....

    cheers,

    Danny
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Well, yes I do run out of pbufs, but that is not the point here, because a call to recvfrom() will release the pbuf it just read from.

    The point is, that if I ran out of pbufs (wich is intended) and start reading/releasing them with recvfrom(), the function will block after getting about ten data packages, even though it is used in non blocking mode. Both select() and lwip_ioctl() indicate that there is data left, what is absolutely understandable, because more than ten pbufs are specified in the projects properties.

    Now I would like to know if this could be a bug in lwip or if I have to adjust some of the lwip properties (currently I am using the default values) or if there is any other plausible explanation for this behavior.

    Thanks in advance for all helpful info you can give!

    --wolf