Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed
HTTPLog.h
00001 #ifndef HTTPLOG_H 00002 #define HTTPLOG_H 00003 00004 #include "HTTPServer.h" 00005 00006 class HTTPLog : public HTTPHandler { 00007 public: 00008 HTTPLog(const char *prefix) : HTTPHandler(prefix) {} 00009 HTTPLog(HTTPServer *server, const char *prefix) : HTTPHandler(prefix) { server->addHandler(this); } 00010 00011 private: 00012 virtual HTTPHandle action(HTTPConnection *con) const { 00013 struct ip_addr ip = con->pcb()->remote_ip; 00014 printf("%hhu.%hhu.%hhu.%hhu %s %s", (ip.addr)&0xFF, (ip.addr>>8)&0xFF, (ip.addr>>16)&0xFF, (ip.addr>>24)&0xFF, (con->getType() == POST? "POST" : "GET"), con->getURL()); 00015 return HTTP_AddFields; 00016 } 00017 }; 00018 00019 #endif
Generated on Tue Jul 12 2022 19:17:23 by 1.7.2