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 SimpleSocket mbed-rtos mbed
httpclient.cpp
00001 #include "SimpleSocket.h" 00002 00003 void httpclient() { 00004 printf("URL => "); 00005 char url[128]; 00006 scanf("%s", url); 00007 00008 char hostpart[64], host[64], path[128]; 00009 int port = 80; 00010 sscanf(url, "http://%[^/]%s", hostpart, path); 00011 sscanf(hostpart, "%[^:]:%d", host, &port); 00012 00013 ClientSocket socket(host, port); 00014 00015 if (socket) { 00016 socket.printf("GET %s HTTP/1.0\r\n\r\n", path); 00017 00018 while (socket) { 00019 if (socket.available()) { 00020 char buf[128] = {}; 00021 socket.read(buf, sizeof(buf) - 1); 00022 printf("%s", buf); 00023 } 00024 } 00025 } 00026 }
Generated on Mon Jul 18 2022 00:17:10 by
1.7.2