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: mbed Socket lwip-eth lwip-sys lwip
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 00004 Serial pc(USBTX, USBRX); 00005 00006 int main() 00007 { 00008 EthernetInterface eth; 00009 eth.init(); //Use DHCP 00010 eth.connect(); 00011 printf("IP Address is %s\n", eth.getIPAddress()); 00012 00013 TCPSocketConnection sock; 00014 sock.connect("mbed.org", 80); 00015 00016 char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n"; 00017 sock.send_all(http_cmd, sizeof(http_cmd)-1); 00018 00019 char buffer[300]; 00020 int ret; 00021 while (true) { 00022 ret = sock.receive(buffer, sizeof(buffer)-1); 00023 if (ret <= 0) 00024 break; 00025 buffer[ret] = '\0'; 00026 printf("Received %d chars from server:\n%s\n", ret, buffer); 00027 } 00028 00029 sock.close(); 00030 00031 eth.disconnect(); 00032 00033 while(1) {} 00034 }
Generated on Tue Jul 12 2022 19:56:59 by
