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.
Dependencies: EthernetNetIf SimpleSocket 1.0 mbed
Diff: Example/echoserver.cpp
- Revision:
- 22:fc886208c19b
- Parent:
- 21:a3cf1f055a4d
--- a/Example/echoserver.cpp Fri Sep 09 09:49:45 2011 +0000 +++ b/Example/echoserver.cpp Fri Sep 09 10:31:44 2011 +0000 @@ -5,7 +5,7 @@ int echoserver(int port) { printf("** echoserver, port = %d\n", port); - + DigitalOut led1(LED1), led2(LED2); ServerSocket server(port); Timer timer; @@ -14,10 +14,10 @@ while (true) { if (ClientSocket socket = server.accept()) { while (socket.connected()) { - char buf[1]; - int len = socket.read(buf, sizeof(buf)); - if (len > 0) - socket.write(buf, len); + if (socket.available()) { + int c = socket.read(); + socket.write(c); + } blink(led1, timer); } socket.close();