what does Net::poll actually do?

19 Oct 2011

i am using my mbed as a basic tcp client with a little server app i've written which only receives data. After initally connecting and TCPsocket.send()ing a buffer (and receiving it on the server) successfully, any subsequent calls to Net::poll() causes the mbed to hang. nothing is written to the server. repeatedly calling the following causes the effect (but it works the first time):

char* a=new char[50]; sprintf(a,"helloey!"); int lensent=skt.send(a,strlen(a)); Net::poll();

i can't think what the problem might be. has anyone else encountered this problem? what does Net::poll() actually do in this context?

19 Oct 2011

Have you looked at the traffic on the Wire? (use Wireshark).

See if either mbed or the server is aborting the connexion (Wireshark shows [RST] at the packet). If the connexion fails in TCP, send() will fail. You could set up a handler for TCPerror, to see whether anything is wrong when send() is called.

Also, beware that the TCPsocket API appears to provide no route to important LwIP functions, such as tcp_output. This means that small packets may or may not be sent quickly enough for you, because the socket waits for a bigger packet.

I have found the NetServices stack to be not entirely reliable, and very slow in response time. Like 2 packets per second, back to back. On the other hand, the antique stack developed by Rolf 2 years ago works very well, and provides examples that allow direct use of the LwIP API, with huge benefits in speed. Try the LwIP Client or Server, they're easy to understand, and hack:

http://mbed.org/projects/cookbook/wiki/EMAC/purehttpc

Michael Wei's Server uses this method, too, to produce dynamically updated pages, and this works excellently well:

http://mbed.org/users/no2chem/programs/EthernetTester/6095m