1.4. Talking HTTP

Another, more flexible possibility is it, to set up a simple web server, that handles complete HTTP transactions. As a side effect it does not only handle XML-RPC requests but also passes data to or from a web browser or deletes files which is also part of the HTTP standard.

1.4.1. The Server


  TcpIpConnection conn (0x7f000001, 80);  1
  HttpProtocol prot(&conn, conn);
  HttpServer http_server (&prot);

  Dispatcher rpc_server(&conn); 2
  http_server.setRpcDispatcher(&rpc_server); 3
  http_server.setHttpRoot("/http-directory/public_html");  4

  rpc_server.addMethod(&testcall,  5
                        "struct",
                        "testcall",
                        "int, int"
                        "Testcase with a c-function");

  http_server.runPicoHttpd(); 6

1

Accept connections to localhost on port 80 (web browser access).

2

Set up an XML-RPC dispatcher.

3

Let the HTTP server know about the rpc-dispatcher.

4

This the internal root of the HTTP server.

5

Add a method including signature for parameters and description.

6

Run forever ...

handbook/index.html