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:
- 4:59056313fbfa
- Child:
- 5:168917e0564c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Example/echoserver.cpp Tue Aug 16 12:30:11 2011 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" +#include "EthernetNetIf.h" +#include "SimpleSocket.h" + +int echoserver() { + DigitalOut led1(LED1); + DigitalOut led2(LED2); + + ServerSocket server(1234); + + Timer timer; + timer.start(); + + while (true) { + Net::poll(); + if (ClientSocket *clientSocket = server.accept()) { + while (clientSocket->connected()) { + char buf[8]; + int len = clientSocket->read(buf, sizeof(buf)); + if (len > 0) + clientSocket->write(buf, len); + + if (timer.read() > 10) { + timer.reset(); + timer.start(); + led1 = !led1; + } + } + } + if (timer.read() > 1) { + timer.reset(); + timer.start(); + led2 = !led2; + } + } +} \ No newline at end of file