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/echoclient.cpp
- Revision:
- 12:52170a866d4a
diff -r 04c0acd7f510 -r 52170a866d4a Example/echoclient.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Example/echoclient.cpp Fri Aug 19 02:17:01 2011 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+#include "SimpleSocket.h"
+
+void echoclient(char *server, int port, char *message) {
+ printf("** echoclient **\n");
+
+ ClientSocket socket(server, port);
+
+ for (int i = 0; i < 10; i++) {
+ if (socket.connected()) {
+ printf("Sending message: %s", message);
+ socket.writef("%s\n", message);
+ while (socket.connected()) {
+ if (socket.available()) {
+ char buf[128];
+ int len = socket.read(buf, sizeof(buf) - 1);
+ buf[len] = '\0';
+ printf("Received from server: len = %d, %s\n", len, buf);
+ break;
+ }
+ }
+ }
+ }
+
+ printf("Closing socket\n");
+ socket.close();
+ printf("Done\n");
+}
\ No newline at end of file