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:
- 3:3fbf0efec25a
- Parent:
- 2:563aa530f0dd
- Child:
- 6:dd8d1cf1cb9c
- Child:
- 9:a640b18e5931
--- a/main.cpp Thu Jul 26 16:45:55 2012 +0000
+++ b/main.cpp Wed Aug 01 13:03:13 2012 +0000
@@ -1,8 +1,8 @@
#include "mbed.h"
#include "EthernetInterface.h"
-const char* ECHO_SERVER_ADDRESS = "10.2.131.73";
-const int ECHO_PORT = 7;
+const char* ECHO_SERVER_ADDRESS = "192.168.0.51";
+const int ECHO_SERVER_PORT = 7;
int main() {
EthernetInterface eth;
@@ -10,21 +10,21 @@
eth.connect();
printf("IP Address is %s\n", eth.getIPAddress());
- TCPSocketConnection sock;
- while (sock.connect(ECHO_SERVER_ADDRESS, ECHO_PORT) < 0) {
- printf("Unable to connect to (%s) on port (%d)\n", ECHO_SERVER_ADDRESS, ECHO_PORT);
+ 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);
}
char hello[] = "Hello World\n";
- sock.send_all(hello, sizeof(hello) - 1);
+ socket.send_all(hello, sizeof(hello) - 1);
char buf[256];
- int n = sock.receive(buf, 256);
+ int n = socket.receive(buf, 256);
buf[n] = '\0';
printf("%s", buf);
- sock.close();
+ socket.close();
eth.disconnect();
while(true) {}
