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: EthernetInterface mbed-rtos mbed
Fork of TCPEchoClient by
Diff: main.cpp
- Revision:
- 9:a640b18e5931
- Parent:
- 3:3fbf0efec25a
- Child:
- 11:a134fd8cbe67
--- a/main.cpp	Wed May 14 15:24:47 2014 +0000
+++ b/main.cpp	Mon May 04 22:46:26 2015 +0000
@@ -1,29 +1,35 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
 
-const char* ECHO_SERVER_ADDRESS = "192.168.0.51";
+const char* ECHO_SERVER_ADDRESS = "192.168.2.2";
 const int ECHO_SERVER_PORT = 7;
 
 int main() {
     EthernetInterface eth;
     eth.init(); //Use DHCP
     eth.connect();
-    printf("IP Address is %s\n", eth.getIPAddress());
+    printf("\nClient IP Address is %s\n", eth.getIPAddress());
     
+    // Connect to Server
     TCPSocketConnection socket;
     while (socket.connect(ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT) < 0) {
         printf("Unable to connect to (%s) on port (%d)\n", ECHO_SERVER_ADDRESS, ECHO_SERVER_PORT);
         wait(1);
     }
+    printf("Connected to Server at %s\n",ECHO_SERVER_ADDRESS);
     
-    char hello[] = "Hello World\n";
+    // Send message to server
+    char hello[] = "Hello World";
+    printf("Sending  message to Server : '%s' \n",hello);
     socket.send_all(hello, sizeof(hello) - 1);
     
+    // Receive message from server
     char buf[256];
     int n = socket.receive(buf, 256);
     buf[n] = '\0';
-    printf("%s", buf);
+    printf("Received message from server: '%s'\n", buf);
     
+    // Clean up
     socket.close();
     eth.disconnect();
     
    