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
Example/echoserver.cpp
- Committer:
- yamaguch
- Date:
- 2011-08-17
- Revision:
- 8:b35559c14d17
- Parent:
- 7:d57efbdb6517
- Child:
- 10:62ce72ee3e91
File content as of revision 8:b35559c14d17:
#include "mbed.h" #include "EthernetNetIf.h" #include "SimpleSocket.h" int echoserver(int port) { DigitalOut led1(LED1); DigitalOut led2(LED2); ServerSocket server(port); Timer timer; timer.start(); while (true) { 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; } } }