I found a strange behavior in TCPSocketServer class from mbed new EthernetInterface library.
This is the code:
#include "mbed.h"
#include "EthernetInterface.h"
int main() {
EthernetInterface eth;
eth.init(); //Use DHCP
eth.connect();
printf("IP Address is %s\n", eth.getIPAddress());
TCPSocketServer m_Svr;
m_Svr.bind (80);
m_Svr.listen(1);
m_Svr.set_blocking (false, 900);
while (1) {
TCPSocketConnection Clnt;
if (m_Svr.accept(Clnt) < 0) {
printf("no connection\n");
} else {
printf("Client (IP=%s) is connected !\n", Clnt.get_address());
}
}
}
If I run this code, at the beginning everything works fine, and "no connection" message appears every 900 milliseconds.
Then I open a browser in my PC (both mbed and PC are connected to the same network), I write "http: [mbed IP address]" in navigation bar and I press "Enter". Mbed message switch to "Client IP: xxxx is connected!", and then it returns to "no connection" again.
So far, everything works as expected.
But: after re-connecting a few times (with "F5" key, in browser), suddenly mbed stop responding to connections (it remains displaying "no connection" forever) or, sometimes, it begins to behave like in blocking mode (i.e., don't display "no connection" anymore, but still display "Client IP: is connected" whenever I press "F5"), wich is even more strange...
I found a strange behavior in TCPSocketServer class from mbed new EthernetInterface library.
This is the code:
If I run this code, at the beginning everything works fine, and "no connection" message appears every 900 milliseconds.
Then I open a browser in my PC (both mbed and PC are connected to the same network), I write "http: [mbed IP address]" in navigation bar and I press "Enter". Mbed message switch to "Client IP: xxxx is connected!", and then it returns to "no connection" again.
So far, everything works as expected.
But: after re-connecting a few times (with "F5" key, in browser), suddenly mbed stop responding to connections (it remains displaying "no connection" forever) or, sometimes, it begins to behave like in blocking mode (i.e., don't display "no connection" anymore, but still display "Client IP: is connected" whenever I press "F5"), wich is even more strange...