Распределенные вычисления: технология Microsoft RPC. Часть1. Фертиков В.В. - 18 стр.

UptoLike

Составители: 

18
/* Формирование строки связывания в требуемом формате */
status = RpcStringBindingCompose(
pszUuid,
pszProtocolSequence,
pszNetworkAddress,
pszEndpoint,
pszOptions,
&pszStringBinding);
printf("RpcStringBindingCompose returned 0x%x\n",status);
printf("pszStringBinding = %s\n", pszStringBinding);
if (status) exit(status);
/* Установка дескриптора связывания */
status = RpcBindingFromStringBinding(
pszStringBinding,
&hello_IfHandle);
printf("RpcBindingFromStringBinding returned 0x%x\n",
status);
if (status) exit(status);
printf("Calling the remote procedure 'HelloProc'\n");
printf("Print the string '%s' on the server\n",
pszString);
RpcTryExcept {
HelloProc(pszString); // удаленный вызов
printf("Calling the remote procedure 'Shutdown'\n");
Shutdown(); // остановка сервера (используется далее)
}
RpcExcept(1) {
ulCode = RpcExceptionCode();
printf("Runtime reported exception 0x%lx \n",ulCode);
}
RpcEndExcept
/* Удаленные вызовы сделаны. */
/* Освобождение строки и дескриптора связывания */
status = RpcStringFree(&pszStringBinding);
printf("RpcStringFree returned 0x%x\n", status);
if (status) exit(status);
status = RpcBindingFree(&hello_IfHandle);
printf("RpcBindingFree returned 0x%x\n", status);
if (status) exit(status);
exit(0);
}
                              18
/* Формирование строки связывания в требуемом формате */
    status = RpcStringBindingCompose(
                       pszUuid,
                       pszProtocolSequence,
                       pszNetworkAddress,
                       pszEndpoint,
                       pszOptions,
                       &pszStringBinding);
    printf("RpcStringBindingCompose returned 0x%x\n",status);
    printf("pszStringBinding = %s\n", pszStringBinding);
    if (status) exit(status);

/* Установка дескриптора связывания */
    status = RpcBindingFromStringBinding(
                        pszStringBinding,
                        &hello_IfHandle);
    printf("RpcBindingFromStringBinding returned 0x%x\n",
            status);
    if (status) exit(status);

     printf("Calling the remote procedure 'HelloProc'\n");
     printf("Print the string '%s' on the server\n",
             pszString);

     RpcTryExcept {
         HelloProc(pszString); // удаленный вызов
         printf("Calling the remote procedure 'Shutdown'\n");

         Shutdown(); // остановка сервера (используется далее)
     }
     RpcExcept(1) {
         ulCode = RpcExceptionCode();
         printf("Runtime reported exception 0x%lx \n",ulCode);
     }
     RpcEndExcept

/*   Удаленные вызовы сделаны. */
/*   Освобождение строки и дескриптора связывания */
     status = RpcStringFree(&pszStringBinding);
     printf("RpcStringFree returned 0x%x\n", status);
     if (status) exit(status);
     status = RpcBindingFree(&hello_IfHandle);
     printf("RpcBindingFree returned 0x%x\n", status);
     if (status) exit(status);

     exit(0);
}