We will start with a basic application created with the NBEclipse Application Wizard. If you are not familiar with creating an application or NBEclipse please refer to the NBEclipse Getting Started Guide before continuing. When running the Application Wizard select the Standard Initialization and Web server options. Once the project is complete, you should have a main.cpp file as shown below:
The system will automatically start the RTOS and UserMain() as a its own task. This simple application is a fully functional network application with a web server.
The init() function will do the following:
The WaitForActiveNetwork() function will wait for an active network link before proceeding, up until the specified timeout.
StartHttp() starts the web server. The default port is 80. If you wish to start on a different port you can specify the port number as a parameter to the function.
The system supports printf() and iprintf(). The iprintf() function (i = integer only) will consume less system resources if you do not need floating point support.
Your application should never return from UserMain(); the while() loop will run forever. The #define TICKS_PER_SECOND should be used with the delay function in case the system ticks per second value is ever modified.