Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of WiflyInterface by
Diff: Socket/TCPSocketServer.cpp
- Revision:
- 10:e19f4c58a137
- Parent:
- 4:0bcec6272784
--- a/Socket/TCPSocketServer.cpp Tue Jan 28 11:00:48 2014 +0200
+++ b/Socket/TCPSocketServer.cpp Fri Dec 16 02:50:56 2016 +0000
@@ -87,4 +87,34 @@
}
}
}
+}
+
+int TCPSocketServer::acceptWithTimeout(TCPSocketConnection& connection, int timeout) {
+ int nb_available = 0, pos = 0;
+ char c;
+ string str;
+ bool o_find = false;
+ time_t currTime = time(NULL);
+ while (1) {
+ while(!wifi->readable() && time(NULL)-currTime<=timeout);
+ if (time(NULL)-currTime>timeout) {
+ wifi->flush();
+ return -1;
+ }
+ nb_available = wifi->readable();
+ for (int i = 0; i < nb_available; i++) {
+ c = wifi->getc();
+ if (c == '*') {
+ o_find = true;
+ }
+ if (o_find && c != '\r' && c != '\n') {
+ str += c;
+ pos = str.find("*OPEN*");
+ if (pos != string::npos) {
+ wifi->flush();
+ return 0;
+ }
+ }
+ }
+ }
}
\ No newline at end of file
