]> git.sur5r.net Git - freertos/blob - Demo/WizNET_DEMO_GCC_ARM7/HTTP_Serv.c
Update to V4.4.0.
[freertos] / Demo / WizNET_DEMO_GCC_ARM7 / HTTP_Serv.c
1 /*\r
2         FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.\r
3 \r
4         This file is part of the FreeRTOS.org distribution.\r
5 \r
6         FreeRTOS.org is free software; you can redistribute it and/or modify\r
7         it under the terms of the GNU General Public License as published by\r
8         the Free Software Foundation; either version 2 of the License, or\r
9         (at your option) any later version.\r
10 \r
11         FreeRTOS.org is distributed in the hope that it will be useful,\r
12         but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14         GNU General Public License for more details.\r
15 \r
16         You should have received a copy of the GNU General Public License\r
17         along with FreeRTOS.org; if not, write to the Free Software\r
18         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
19 \r
20         A special exception to the GPL can be applied should you wish to distribute\r
21         a combined work that includes FreeRTOS.org, without being obliged to provide\r
22         the source code for any proprietary components.  See the licensing section \r
23         of http://www.FreeRTOS.org for full details of how and when the exception\r
24         can be applied.\r
25 \r
26         ***************************************************************************\r
27         See http://www.FreeRTOS.org for documentation, latest information, license \r
28         and contact details.  Please ensure to read the configuration and relevant \r
29         port sections of the online documentation.\r
30 \r
31         Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along\r
32         with commercial development and support options.\r
33         ***************************************************************************\r
34 */\r
35 \r
36 \r
37 /* Standard includes. */\r
38 #include <stdlib.h>\r
39 \r
40 /* Scheduler include files. */\r
41 #include "FreeRTOS.h"\r
42 #include "task.h"\r
43 \r
44 /* Application includes. */\r
45 #include "tcp.h"\r
46 \r
47 /* Misc constants. */\r
48 #define tcpPOLL_DELAY                                   ( ( portTickType ) 12 / portTICK_RATE_MS )\r
49 #define tcpCONNECTION_DELAY                             ( ( portTickType ) 8 / portTICK_RATE_MS )\r
50 /*-----------------------------------------------------------*/\r
51 \r
52 /*\r
53  * This task initialises the hardware then processes one TCP connection at a\r
54  * time.  When an HTTP client connects we just simply send a single page then\r
55  * disconnect - reset the socket data and wait for the next connection.\r
56  */\r
57 void vHTTPServerTask( void *pvParameters )\r
58 {\r
59         /* Reset the network hardware. */\r
60         vTCPHardReset();\r
61 \r
62         /* Loop, processing connections are they arrive. */\r
63         for( ;; )\r
64         {\r
65                 /* Initialise the TCP interface.\r
66 \r
67                 The current minimal implementation does not check for buffer overflows\r
68                 in the WIZnet hardware, so simply resets all the buffers for each\r
69                 connection - and only processes one connection at a time. */\r
70                 if( lTCPSoftReset() )\r
71                 {         \r
72                         /* Create the socket that is going to accept incoming connections. */\r
73                         if( lTCPCreateSocket() )\r
74                         {\r
75                                 /* Wait for a connection. */\r
76                                 vTCPListen();\r
77 \r
78                                 /* Process connections as they arrive.  This function will only\r
79                                 return once the connection has been closed. */\r
80                                 lProcessConnection();\r
81                         }\r
82                 }\r
83 \r
84                 /* If we get here then the connection completed or failed.  Wait a \r
85                 while then try or start again. */\r
86                 vTaskDelay( tcpCONNECTION_DELAY );              \r
87         }\r
88 }\r
89 \r