Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 6 months ago.
Net::poll();
This comes from an HelloWorld Server example with the old Ethernet Interface
What does this actually do? Is this like:
poll() is used to check on the state of a socket in a set of sockets. The set can be tested to see if any socket can be written to, read from or if an error occurred.
Or does this means:
check WHAT and not IF there is something comming in in the socket.
thnx!
1 Answer
11 years, 6 months ago.
With the old LwIP libraries, which cannot run under RTOS, data is not moved anywhere until the net::poll() function is called.
For example, say you have set up a connexion to a remote device (you issued a LwIP tcp_connect() ). This will send the introductory SYN to the remote end, but when you receive some data back, this will not be available until you have called a net::poll().
when the net::poll() is called, the LwIP layer will check the receive buffer for data, and start your receive callback if there is something waiting.
Yes, it's a bit manual-operated - but it actually works very reliably. Used with the LwIP raw TCP or UDP API, it is much more robust than any of the available high-level libraries, IME.
http://lwip.wikia.com/wiki/Raw/TCP