This mechanism is supposed to be used such that an ECLiPSe server loop is set up, and the host program resumes ECLiPSe repeatedly to have a request served.
Note that, by default, ECLiPSe is set up as a server which calls posted goals. This is such a general mechanism that it is often not necessary to write a special-purpose server loop.
% ECLiPSe server code
start_server :-
eclipse_server(dummy).
eclipse_server(PrevResult) :-
yield(PrevResult, Request),
process_request(Request, NewResult),
eclipse_server(NewResult).
// C++ client code
ec_init();
post_goal("start_server");
if (EC_resume() == EC_yield)
{
for(;;)
{
// create a request
...
if (EC_resume(request, result) != EC_yield);
break;
...
// use the result
}
}