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 4180_Lab2_TCPSocket_HelloWorld by
Revision 15:d64c0edea178, committed 2016-09-25
- Comitter:
- jeremycai3721
- Date:
- Sun Sep 25 19:04:17 2016 +0000
- Parent:
- 14:72be2b8b7f24
- Commit message:
- CodeShare
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed May 14 15:07:26 2014 +0000
+++ b/main.cpp Sun Sep 25 19:04:17 2016 +0000
@@ -1,11 +1,12 @@
#include "mbed.h"
#include "EthernetInterface.h"
+Serial pc(USBTX, USBRX);
int main() {
EthernetInterface eth;
eth.init(); //Use DHCP
eth.connect();
- printf("IP Address is %s\n", eth.getIPAddress());
+ pc.printf("IP Address is %s\n", eth.getIPAddress());
TCPSocketConnection sock;
sock.connect("mbed.org", 80);
@@ -17,10 +18,14 @@
int ret;
while (true) {
ret = sock.receive(buffer, sizeof(buffer)-1);
- if (ret <= 0)
+ if (ret <= 0) {
+ pc.printf("I am here");
break;
+ }
+
+
buffer[ret] = '\0';
- printf("Received %d chars from server:\n%s\n", ret, buffer);
+ pc.printf("Received %d chars from server:\n%s\n", ret, buffer);
}
sock.close();
