Simple code for comunication via TCP between the mbed and PC.
Dependencies: EthernetInterface SimpleSocket mbed-rtos mbed
Fork of SimpleSocketExamples by
examples/echoserver.cpp
- Committer:
- yamaguch
- Date:
- 2013-02-04
- Revision:
- 0:6dc3cfd058c6
File content as of revision 0:6dc3cfd058c6:
#include "SimpleSocket.h" void echoserver() { ServerSocket server(1234); printf("server: %s:1234\n", EthernetInterface::getIPAddress()); while (true) { ClientSocket socket = server.accept(); if (socket) { while (socket) { char buf[80]; int len = socket.read(buf, sizeof(buf)); if (len > 0) socket.write(buf, len); } socket.close(); } wait(1.0); } }