Server configuration, Cygnumhttpdserverport, Cygdathttpdserverid – Comtrol eCos User Manual

Page 634: Cygnumhttpdthreadcount, Cygnumhttpdthreadpriority, Cygnum_httpd_server_port, Cygdat_httpd_server_id, Cygnum_httpd_thread_count, Cygnum_httpd_thread_priority, Cygnum_httpd_thread_stack_size

Advertising
background image

Chapter 48. Embedded HTTP Server

When a pattern is matched, the hander function is called. It has the following prototype:

cyg_bool cyg_httpd_handler(FILE *client,

char *filename,

char *formdata,

void *arg);

The

client

argument is the TCP connection to the client: anything output through this stream will be returned

to the browser. The

filename

argument is the filename from the HTTP request and the

formdata

argument

is any form response data, or NULL if none was sent. The

arg

argument is the user defined value from the table

entry.

The handler is entirely responsible for generating the response to the client, both HTTP header and content. If
the handler decides that it does not want to generate a response it can return

false

, in which case the table scan

is resumed for another match. If no match is found, or no handler returns true, then a default response page is
generated indicating that the requested page cannot be found.

Finally, the server thread closes the connection to the client and loops back to accept a new connection.

Server Configuration

The HTTP server has a number of configuration options:

CYGNUM_HTTPD_SERVER_PORT

This option defines the TCP port that the server will listen on. It defaults to the standard HTTP port number 80. It
may be changed to a different number if, for example, another HTTP server is using the main HTTP port.

CYGDAT_HTTPD_SERVER_ID

This is the string that is reported to the client in the "Server:" field of the HTTP header.

CYGNUM_HTTPD_THREAD_COUNT

The HTTP server can be configured to use more than one thread to service HTTP requests. If you expect to serve
complex pages with many images or other components that are fetched separately, or if any pages may take a long
time to send, then it may be useful to increase the number of server threads. For most uses, however, the connection
queuing in the TCP/IP stack and the speed with which each page is generated, means that a single thread is usually
adequate.

CYGNUM_HTTPD_THREAD_PRIORITY

The HTTP server threads can be run at any priority. The exact priority depends on the importance of the server
relative to the rest of the system. The default is to put them in the middle of the priority range to provide reasonable
response without impacting genuine high priority threads.

530

Advertising