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:
- 10:62ce72ee3e91
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Example/echoclient.cpp Thu Aug 18 08:46:47 2011 +0000
@@ -0,0 +1,24 @@
+#include "mbed.h"
+#include "SimpleSocket.h"
+
+void echoclient(char *server, int port, char *message) {
+ ClientSocket socket(server, port);
+ while (!socket.connected())
+ ;
+ printf("Connected to server\n");
+ if (socket.connected()) {
+ socket.read();// dummy read
+ printf("Sending message\n");
+ socket.writef("%s\n", message);
+ while (socket.connected()) {
+ if (socket.available()) {
+ char buf[128];
+ int len = socket.read(buf, sizeof(buf));
+ buf[len] = '\0';
+ printf("Received from server: len = %d, %s\n", len, buf);
+ break;
+ }
+ }
+ }
+ printf("Done\n");
+}
\ No newline at end of file