Tutorial: Building an Rogue Wave Server Application > Designing the Server Object Model > Executing the Server Main Loop
 
Executing the Server Main Loop
This section explains how to execute the main loop for the Network object server.
1. #include <ilserver/tcpmvproc.h>
2. #include <ilserver/mvserver.h>
3. #include <network.h>
4.
5. int main(int argc, char **argv){
6.     if (!IlsTcpMvProcess::Initialize(argc, argv)){
7.         cerr << "Init. of Server process failed" << endl;
8.         IlsExit(1)
9.     }
10.     if (!IlsMvServer::Initialize(argc, argv)){
11.         cerr << "Init. of server failed" << endl;
8.         IlsExit(1)
9.     }
10.    NetworkP network=BuildNetwork();
11.    IlsMvServer::run();
12.    return 0;
13.}
The function IlsTcpMvProcess::Initialize (line 6) initializes the Rogue Wave® Server MvTcp communication layer of a dynamic view server process—whether this process is a server or a component process. To run the application on another communication layer, you only need to modify this initialization.
For instance, if you want to use Orbix®, all you have to do is replace this function call by:
IlsOrbixMvProcess::Initialize(argc, argv);
At process initialization, the following options are parsed:
*-ilsn <server_name> or -ilsname <server_name>—This option registers the object server process with a logical name. If you use the Rogue Wave Server communication layer, you must first start the logical mapper tcpd on the host where the server runs. This executable is delivered in the bin directory of the server distribution.
*-ilss <timeOut> or -ilsstop <timeOut>—This option declares a timeout period for the view server execution loop. This execution loop exits if no component requests are received within the lapse of time specified by the timeOut parameter.
The static member function IlsMvServer::Initialize (line 10) initializes a dynamic view server. It takes the command line options as its arguments. It parses and interprets the following options:
*-ilsr <resource_file>—This option is used to specify that all the specification files listed in the resource file (.ls file) should be loaded by the server. It lets you start the server together with a set of predefined views. This option uses the environment variable ILSPATH to search for the resource file and for the view specification files.
*-ilsd <specif_file>—This option is used to load a view specification file
(.ils or .ilv). Like the previous option, it locates the file using the environment variable ILSPATH.
To execute a server, you have to create at least one server object, which can be empty, and register it with the server using an identifier. This is done by the function BuildNetwork which is called on line 10. (This function is detailed in the next section.)
The run function (line 11) starts the server execution loop.

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.