Lab2_web / Mbed 2 deprecated webserverBlinky

Dependencies:   mbed

Fork of webserverBlinky by RealTimeCompLab2

Revision:
33:b5a86ff03f3d
Parent:
32:512228c29209
Child:
34:8a6fbc73a7f1
diff -r 512228c29209 -r b5a86ff03f3d main.cpp
--- a/main.cpp	Thu Jan 05 02:59:17 2017 +0000
+++ b/main.cpp	Thu Jan 05 03:23:18 2017 +0000
@@ -514,8 +514,10 @@
 
     int incomingLen = dataLen; // remember length of incoming packet
     dataLen = 0; // most of our responses will have zero TCP data, only a header
-
-    if ( ((flagsTCP & ~TCP_FLAG_ACK) == 0) && ((flagsTCP & TCP_FLAG_ACK) != 0) ) {
+    
+    if ( ((flagsTCP & TCP_FLAG_FIN) != 0) && ((flagsTCP & TCP_FLAG_ACK) != 0) ) {
+          return; // ACK and FIN - we are done
+    } else if ( ((flagsTCP & ~TCP_FLAG_ACK) == 0) && ((flagsTCP & TCP_FLAG_ACK) != 0) ) {
         if (incomingLen > 0) {  // they sent data in the ack
             ack = seq + incomingLen; // acknowledge the number of bytes they sent
             seq = ppp.seq; // confirm our current sequence position
@@ -550,7 +552,7 @@
             memset(dataStart,'x', dataLen ); // initialize the block
             int n=0; // number of bytes we have printed so far
             n=n+sprintf(n+dataStart,"HTTP/1.1 200 OK\r\nServer: PPP-Blinky\r\n"); // http header
-            n=n+sprintf(n+dataStart,"Content-Length: 378\r\n"); // http header
+            n=n+sprintf(n+dataStart,"Content-Length: 377\r\n"); // http header
             n=n+sprintf(n+dataStart,"Content-Type: text/html; charset=us-ascii\r\n\r\n"); // http header
             int nHeader=n; // byte total of all headers
             n=n+sprintf(n+dataStart,"<html><head><title>mbed-PPP-Blinky</title><script>window.onload=function()"); // html