The following code fragments are intended to give an idea how a client might import both the hello_svc server's interface and its exported serviceability interface.
Note that (for brevity's sake) status return checks have been omitted from this code.
/* Import binding info from namespace. */
for (server_num = 0; server_num < nservers; server_num++)
{
/* Begin the binding import loop. */
rpc_ns_binding_import_begin(rpc_c_ns_syntax_dce,
server_name[server_num], hello_v1_0_c_ifspec,
&obj_uuid, &import_context, &status);
/* Begin the svc binding import loop. */
rpc_ns_binding_import_begin(rpc_c_ns_syntax_dce,
server_name[server_num], NULL,
&obj_uuid, &svc_import_context, &status);
/* Import bindings one at a time. */
while (1)
{
rpc_ns_binding_import_next(import_context,
&bind_handle[server_num], &status);
rpc_ns_binding_import_next(svc_import_context,
&svc_bind_handle[server_num], &status);
/* Select, say, the first binding over UDP. */
rpc_binding_to_string_binding(bind_handle[server_num],
&string_binding, &status);
rpc_binding_to_string_binding(svc_bind_handle[server_num],
&svc_string_binding, &status);
rpc_string_binding_parse(string_binding, NULL,
&protseq, NULL, NULL, NULL, &status);
rpc_string_binding_parse(svc_string_binding, NULL,
&svc_protseq, NULL, NULL, NULL, &status);
rpc_string_free(&string_binding, &status);
ret = strcmp((char *)protseq, "ncadg_ip_udp");
rpc_string_free(&protseq, &status);
rpc_string_free(&svc_string_binding, &status);
svc_ret = strcmp((char *)svc_protseq, "ncadg_ip_udp");
rpc_string_free(&svc_protseq, &status);
if ((svc_ret == 0) || (ret == 0))
{
break;
}
}
/* End the binding import loop. */
rpc_ns_binding_import_done(&import_context, &status);
rpc_ns_binding_import_done(&svc_import_context, &status);
}
/* Annotate binding handles for security. */
for (server_num = 0; server_num < nservers; server_num += 1)
rpc_binding_set_auth_info(bind_handle[server_num],
SERVER_PRINC_NAME, rpc_c_protect_level_pkt_integ,
rpc_c_authn_dce_secret, NULL /*default login context*/,
rpc_c_authz_name, &status);
for (server_num = 0; server_num < nservers; server_num += 1)
rpc_binding_set_auth_info(svc_bind_handle[server_num],
SERVER_PRINC_NAME, rpc_c_protect_level_pkt_integ,
rpc_c_authn_dce_secret, NULL /*default login context*/,
rpc_c_authz_name, &status);