OSF DCE Application Development Guide--Core Components

OSF DCE Application Development Guide—Core Components
2.6.3 Starting and Stopping Servers
A server typically runs as persistent process or is started on demand when a client makes
a remote procedure call to it. Management applications can start remote servers by using
the dced_server_start( ) routine. This is a srvrconf routine that takes as input server
configuration data in the form of an attribute list.
Once a server has started, it tends to remain running until an administrator or
management application stops it, but some applications may stop themselves if, for
example, they do not detect activity within a specified time. To stop remote servers,
applications can use the dced_server_stop() routine.
The following example shows how an application starts or stops a server:
dced_binding_handle_t dced_bh, conf_bh, exec_bh;
server_t conf, exec;
dced_string_t server_name;
uuid_t srvrconf_id, srvrexec_id;
error_status_t status;
.
.
.
/* Toggle the Starting or Stopping of a Server */
dced_binding_create("srvrconf@hosts/somehost",
dced_c_binding_syntax_default,
&conf_bh,
&status);
dced_binding_create("srvrexec@hosts/somehost",
dced_c_binding_syntax_default,
&exec_bh,
&status);
dced_inq_id(exec_bh, server_name, &srvrexec_id, &status);
if(status != error_status_ok) {
puts("Server is NOT running.");
dced_inq_id(conf_bh, server_name, &srvrconf_id, &status);
dced_server_start(conf_bh, &srvrconf_id, NULL, &srvrexec_id, &status);
}
else {
puts("Server is RUNNING.");
dced_server_stop(exec_bh, &srvrexec_id, srvrexec_stop_rpc, &status);
}
dced_binding_free(conf_bh, &status);
dced_binding_free(exec_bh, &status);
dced_binding_create()
These routines create dced bindings to the srvrconf and
srvrexec portions of the server management service on a
specified host. The binding handles created are used in all
subsequent calls to appropriate dced API routines.
dced_inq_id()
This routine returns the UUID that dced associates with the
2 22 Tandem Computers Incorporated 124245