The lib with which to make LPC1768 a simple HTTP server. This have not yet implemented. fopen() DOESN'T WORK after EthernetInterface::connect() is called as using mbed-os 5.4~. See also https://os.mbed.com/questions/80658/HardFault-occurs-when-fopen-is-called-af/ or https://github.com/ARMmbed/mbed-os/issues/6578 and https://github.com/ARMmbed/mbed-os/issues/6624

Fork of HTTP_SERVER by Akifumi Takahashi

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HTTP_SERVER.h Source File

HTTP_SERVER.h

00001 //HTTP_SERVER.h
00002 #ifndef HTTP_SERVER_H
00003 #define HTTP_SERVER_H
00004 #include "mbed.h"
00005 #include "EthernetInterface.h"
00006 #include "ResponseMessenger.h"
00007 #include "FileHandler.h"
00008 #include "string.h"
00009 #include "filetest.h"
00010 #include <stdlib.h>
00011 using namespace std;
00012 
00013 enum PortNum {
00014      TCP_PORT = 80,
00015 };
00016 /** HttpServer class
00017  *
00018  * This is the class to make a mbed a simple HTTP Server.
00019  */
00020 class HttpServer
00021 {
00022 public:
00023     HttpServer();
00024     ~HttpServer();
00025     /** HTTP SERVER Initialization.
00026      *
00027      *  This function should be called first of all.
00028      *  @return result of init() as boolean.
00029      *  @retval TRUE SACCESS
00030      *  @retval FALSE
00031      */
00032     bool init();
00033     /** Run the surver service while listening flag is true.
00034      *
00035      *  @return state ending.
00036      *  @retval TRUE at error end.
00037      *  @retval FALSE at normal end.
00038      */
00039     bool run();
00040 
00041 private:
00042     //  Handlers
00043     NetworkInterface    *net;    //  Eternet/Wifi
00044     TCPSocket           client_socket;  //  TCP server connection clerk
00045     SocketAddress       client_address; //  Address of client
00046     TCPServer           server; //  TCP server
00047     ResponseMessenger   msger;  //  Handler of Messenge for a client
00048     FileHandler         fhndl;  //  File Handler
00049     //  Param
00050     //bool keep_alive;
00051     bool listening_flag;
00052     bool socket_connection;
00053     uint16_t port;     //Port number
00054     int backlog;           //backlog Number of pending connections that can be queued simultaneously
00055     //  Function
00056     bool analyzeRequest(char*,int,char*&,char*&,char*&);
00057     bool sendResponse(char*,char*,char*);
00058  
00059 };
00060 
00061 #endif