A simple web server that can be bound to either the EthernetInterface or the WiflyInterface.
Dependents: Smart-WiFly-WebServer WattEye X10Svr SSDP_Server
Revision 16:6ebacf2946d8, committed 2013-09-01
- Comitter:
- WiredHome
- Date:
- Sun Sep 01 19:19:08 2013 +0000
- Parent:
- 15:581a21c32962
- Child:
- 17:69ff00ce39f4
- Commit message:
- Default to non-blocking mode, and some minor documentation changes.
Changed in this revision
SW_HTTPServer.cpp | Show annotated file Show diff for this revision Revisions of this file |
SW_HTTPServer.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SW_HTTPServer.cpp Tue Aug 13 11:07:36 2013 +0000 +++ b/SW_HTTPServer.cpp Sun Sep 01 19:19:08 2013 +0000 @@ -105,9 +105,7 @@ server = new TCPSocketServer(); server->bind(port); server->listen(); -// server->set_blocking(false, 0); -// client.set_blocking(false, 0); -// server->accept(client); + server->set_blocking(false, 10); ResetPerformanceData(); PerformanceTimer.start(); } @@ -165,7 +163,7 @@ static state op = Idle; static char * bPtr = headerbuffer; int n; - static int t_ref; // reference point for the PerformanceTimer + static unsigned int t_ref; // reference point for the PerformanceTimer #ifdef DEBUG static state lastOp = Reset; @@ -185,9 +183,9 @@ bPtr = headerbuffer; if (0 == server->accept(client)) { op = Receiving; - t_ref = PerformanceTimer.read_us(); + t_ref = (unsigned int)PerformanceTimer.read_us(); #ifdef DEBUG - pc->printf("Accept at %d\r\n", t_ref); + pc->printf("Accept at %u\r\n", t_ref); #endif } break; @@ -723,9 +721,9 @@ } -int HTTPServer::RecordPerformanceData(SW_PerformanceParam * param, int refTime) +unsigned int HTTPServer::RecordPerformanceData(SW_PerformanceParam * param, unsigned int refTime) { - int t_now = PerformanceTimer.read_us(); + unsigned int t_now = (unsigned int)PerformanceTimer.read_us(); param->TotalTime_us += (t_now - refTime); param->Samples++; if ((t_now - refTime) > param->MaxTime_us)
--- a/SW_HTTPServer.h Tue Aug 13 11:07:36 2013 +0000 +++ b/SW_HTTPServer.h Sun Sep 01 19:19:08 2013 +0000 @@ -321,7 +321,7 @@ bool RegisterHandler(const char * path, Handler callback); /** - * determine if the named file is a supported type (e.g. .htm, .jpg, ...) + * determine if the named file is a supported type (htm, html, jpg, etc) * * if you pass in a filename, it will attempt to extract the extension * and compare that to the list of supported file types. If it finds a @@ -367,7 +367,7 @@ void ParseParameters(char * pString); /** - * Unescape string converts a coded string "in place" into a normal string + * Unescape string converts a coded string "in place" into a normal string. * * A query string will have a number of characters replaced for communication * which includes spaces, quotes, question marks and more. Most of them @@ -404,7 +404,7 @@ bool GetRemoteAddr(char * str, int strSize); /** - * This is used to force a connection to close + * This is used to force a connection to close. * * This switches the module into command mode, performs the close, * then switches it back to data mode. So, this is a time-expensive @@ -415,7 +415,7 @@ bool close_connection(); /** - * Get the size of the largest header. + * Diagnostic to get the size of the largest header. * * This is a diagnostic function, so you can resize the allocated * buffer for your application. With proper sizing, more of the @@ -431,7 +431,7 @@ int GetMaxHeaderSize(); /** - * Get a header value, if it exists. + * Get a value from the http header, if it exists. * * @param hdr is the string to search for (e.g. "Content-Length") * @@ -525,7 +525,7 @@ * @returns the current time which may be used as the reference time * for further measurements. */ - int RecordPerformanceData(SW_PerformanceParam * param, int value); + unsigned int RecordPerformanceData(SW_PerformanceParam * param, unsigned int value); SW_PerformanceData perfData; typedef struct HANDLER {