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:
- 14:c6f5c0833cee
- Child:
- 15:ae9aff693b07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Example/echoclient.cpp Fri Aug 19 02:42:57 2011 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "SimpleSocket.h"
+
+void echoclient(char *server, int port, char *message) {
+
+ ClientSocket client(server, port);
+// wait(1);
+// Net::poll();
+//TCPSOCKET_CONNECTED: Connected to host.
+ if (client.connected()) {
+ // wait(1);
+ // Net::poll();
+ // wait(1);
+ // Net::poll();
+ printf("*** send: %s", message);
+ client.writef(message);
+ printf("*** sent: %s", message);
+ //TCPSOCKET_WRITEABLE: Can write data to buf.
+ //TCPSOCKET_READABLE: Data in buf.
+
+ int total = 0;
+ while (client.connected()) {
+ if (client.available()) {
+ char buf[129];
+ int len = client.read(buf, sizeof(buf) - 1);
+ buf[len] = '\0';
+ printf(buf);
+ total += len;
+ }
+ }
+ printf("\n\n*** Total %d ***\n", total);
+ }
+}
\ No newline at end of file