Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed
HTTPServer/HTTPLog.h@0:a548a085de55, 2010-03-14 (annotated)
- Committer:
- pehrhovey
- Date:
- Sun Mar 14 00:54:12 2010 +0000
- Revision:
- 0:a548a085de55
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pehrhovey | 0:a548a085de55 | 1 | #ifndef HTTPLOG_H |
pehrhovey | 0:a548a085de55 | 2 | #define HTTPLOG_H |
pehrhovey | 0:a548a085de55 | 3 | |
pehrhovey | 0:a548a085de55 | 4 | #include "HTTPServer.h" |
pehrhovey | 0:a548a085de55 | 5 | |
pehrhovey | 0:a548a085de55 | 6 | class HTTPLog : public HTTPHandler { |
pehrhovey | 0:a548a085de55 | 7 | public: |
pehrhovey | 0:a548a085de55 | 8 | HTTPLog(const char *prefix) : HTTPHandler(prefix) {} |
pehrhovey | 0:a548a085de55 | 9 | HTTPLog(HTTPServer *server, const char *prefix) : HTTPHandler(prefix) { server->addHandler(this); } |
pehrhovey | 0:a548a085de55 | 10 | |
pehrhovey | 0:a548a085de55 | 11 | private: |
pehrhovey | 0:a548a085de55 | 12 | virtual HTTPHandle action(HTTPConnection *con) const { |
pehrhovey | 0:a548a085de55 | 13 | struct ip_addr ip = con->pcb()->remote_ip; |
pehrhovey | 0:a548a085de55 | 14 | 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()); |
pehrhovey | 0:a548a085de55 | 15 | return HTTP_AddFields; |
pehrhovey | 0:a548a085de55 | 16 | } |
pehrhovey | 0:a548a085de55 | 17 | }; |
pehrhovey | 0:a548a085de55 | 18 | |
pehrhovey | 0:a548a085de55 | 19 | #endif |