Hello,
we’ve run into a bit of a problem when we switched from blocking sockets to non-blocking sockets. From what we can tell when lwip_recvfrom() is executed it always return EWOULDBLOCK because sock->rcvevent is never incremented and thus
if (((flags & MSG_DONTWAIT) || netconn_is_nonblocking(sock->conn)) &&
(sock->rcvevent <= 0))
is always true. We added some debug-prints in the case NETCONN_EVT_RCVPLUS in event_callback() showing that rcvevent was only incremented when the socket was set as blocking.
I’m having trouble seeing where to probe for the error so if anyone has an idea of where to look, I would be very thankful. Is there any options in lwipopt that could trigger this behavior?
From where is event_callback() triggered normally, it’s added as a callback to the netconnection-object but where is this callback called?
We’re running Lwip 1.40.
Best regards
/Åke Forslund
Åke Forslund
Embedded software engineer
Product Development
NIBE
Tfn: +46 (0)433 273296
E-post: ake.fo...@nibe.se
The callback is called via the macro API_EVENT(), which is mainly called with RECVPLUS from the raw API recv- and accept-callbacks in api_msg.c (those are called from tcpip_thread). However, it is also called with RECVMINUS from netconn_recv_data() in api_lib.c (called from your application thread).
Which type of socket are you using (tcp, udp, raw)?
Could you provide a simple test code that reproduces this, that would make it much easier for me to check.
Thanks,
Simon
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
_______________________________________________
lwip-users mailing list
lwip-...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users
The code you sent works for me with one slight modification: you have to check the return value of lwip_accept() to be >= 0 to enter the first while(1) loop. Better yet, use select to see if accept will succeed (put lSocketRecv on the readset).
You don't check the return value of lwip_accept() although calling it on a nonblocking socket: unless there's actually a new connection pending -1 will be returned. Then of course, the inner while(1) loop is never exited because you will never receive 'q' without a client (lwip_read() always returns -1 as new_fd is -1).
Simon
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
I have pasted your code into test.c in the Win32 port from contrib,
removed your application-specific code, checked the return value of
lwip_accept() and I could successfully connect using telnet.exe provided
with windows XP.
If it's not working for you, that suggests a problem either in your
port or in the client application, I guess... What are the thread
priorities in your system? Are you sure there is only one thread active
in lwIP at a time? Because that's the main difference between the
blocking and your non-blocking version: the blocking version just sits
there and waits for a callback that lets lwip_accept return, while the
non-blocking version calls into tcpip_thread *very* often - if your
threading is broken, there's a good chance this will be revealed by your
way of using non-blocking sockets.
Simon