You copied the Doc URL to your clipboard.

3.5. Initialization routine

The ARM Webserver code itself needs no internal setup. The C compiler will initialize all the internal lists and structures to the appropriate values. However, there are one or two initialization activities that must occur on the target system before it will invoke the webserver:

  • the initiation of a socket listen for webserver operation

  • optionally, the initialization of a user-extended VFS files system.

In the demonstration program, these activities are both addressed in a single function, the initialization routine http_init(), which can be found in the httpport.c file.

To set up the TCP/IP listen, you only need to copy the code from the demonstration program http_init() function into your own file.

A mechanism is needed to sense when an incoming TCP/IP connection is accepted, and tell the webserver. In the example port, a simple polling routine checks the TCP/IP listen every clock tick to see if a connection has formed. If it has, the socket is passed to the webserver by way of http_connection(). The syntax for this call is:

void http_connection(long sock);

The webserver logic will call sys_closesocket() to close the socket when it is no longer needed.

In a more sophisticated system (that is, one with UNIX-like signals) the overhead of polling can usually be avoided by signaling when the TCP/IP connection is ready, and then calling the http_connection() function. Refer to your system documentation for details.

Was this page helpful? Yes No