The SOMOA is the object in the DSOM run-time environment that receives client requests and transforms them into method calls on local server objects. In order for SOMOA to listen for a request, the server program must invoke one of two methods on SOMD_SOMOAObject. If the server program wishes to turn control over to SOMD_SOMOAObject completely (that is, effectively have SOMD_SOMOAObject go into an infinite request-processing loop), then it invokes the execute_request_loop method on SOMD_SOMOAObject as follows:
rc = _execute_request_loop(SOMD_SOMOAObject, &ev, SOMD_WAIT);
Note: This is the way the DSOM provided "generic" server program interacts with SOMD_SOMOAObject.
The execute_request_loop method takes an input parameter of type Flags. The value of this parameter should be either SOMD_WAIT or SOMD_NO_WAIT. If SOMD_WAIT is passed as argument, execute_request_loop will return only when an error occurs. If SOMD_NO_WAIT is passed, it will return when there are no more outstanding messages to be processed. SOMD_NO_WAIT is usually used when the server is being used with the event manager. See "Peer vs. client-server processes" in section 6.9, "Advanced Topics," for more details.
If the server wishes to incorporate additional processing between request executions, it can invoke the execute_next_request method to receive and execute requests one at a time:
for(;;) { rc = _execute_next_request(SOMD_SOMOAObject, &ev, SOMD_NO_WAIT); /* perform app-specific code between messages here, e.g., */ if (!rc) numMessagesProcessed++; }
Just like execute_request_loop, execute_next_request has a Flags argument that can take one of two values: SOMD_WAIT or SOMD_NO_WAIT. If execute_next_request is invoked with the SOMD_NO_WAIT flag and no message is available, the method returns immediately with a return code of SOMDERROR_NoMessages. If a request is present, it will execute it. Thus, it is possible to "poll" for incoming requests using the SOMD_NO_WAIT flag.