Invocação Remota de Procedimentos (RPC)

1,026 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,026
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Invocação Remota de Procedimentos (RPC)

  1. 1. Invocação Remota de Procedimentos (RPC) Alexandre Bragança 2001 DEI / ISEP
  2. 2. Modelo de Programação
  3. 3. Cliente-Servidor
  4. 4. Funcionamento
  5. 5. OSF DCE <ul><li>DCE = Distributed Computing Environment </li></ul><ul><li>OSF = Open Software Foundation </li></ul>
  6. 6. Exemplo Hello World /* file hellop.c */ #include <stdio.h> void HelloProc(unsigned char * pszString) { printf(“%s ”, pszString); } /* file: hello.c, a stand-alone application */ #include “hellop.c” void main(void) { unsigned Char * pszString = “Hello, World”; HelloProc(pszString); }
  7. 7. Definição do Interface <ul><li>//file hello.idl </li></ul><ul><li>[ </li></ul><ul><li>uuid(7a98c250-6808-11cf-b73b-00aa00b677a7), </li></ul><ul><li>version(1.0) </li></ul><ul><li>] </li></ul><ul><li>interface hello </li></ul><ul><li>{ </li></ul><ul><li>void HelloProc([in, string] unsigned char * pszString); </li></ul><ul><li>void Shutdown(void); </li></ul><ul><li>} </li></ul><ul><li>A função Shutdown permite que o cliente ‘desligue’ o servidor </li></ul>
  8. 8. Geração dos Stubs Midl hello.idl Hello.h A incluir no cliente e no servidor hello_c.c Stub Cliente hello_s.c Stub Servidor
  9. 9. Implementação do código do Servidor #include <stdlib.h> #include <stdio.h> #include &quot;hello.h&quot; // header file generated by MIDL compiler void HelloProc(unsigned char * pszString) { printf(&quot;%s &quot;, pszString); } void Shutdown(void) { RPC_STATUS status; printf(&quot;Calling RpcMgmtStopServerListening &quot;); status = RpcMgmtStopServerListening(NULL); printf(&quot;RpcMgmtStopServerListening returned: 0x%x &quot;, status); if (status) { exit(status); } printf(&quot;Calling RpcServerUnregisterIf &quot;); status = RpcServerUnregisterIf(NULL, NULL, FALSE); printf(&quot;RpcServerUnregisterIf returned 0x%x &quot;, status); if (status) { exit(status); } }
  10. 10. Compilação & Execução <ul><li>Compilação </li></ul><ul><ul><li>Cliente: helloc.exe </li></ul></ul><ul><ul><li>helloc. c - Código do cliente </li></ul></ul><ul><ul><li>hello _ c. c – Stub </li></ul></ul><ul><ul><li>Servidor: hellos.exe </li></ul></ul><ul><ul><li>hellos. c – Código do servidor </li></ul></ul><ul><ul><li>hellop. c – Implementação dos serviços </li></ul></ul><ul><ul><li>hello_s. c – Stub do servidor </li></ul></ul><ul><li>Execução </li></ul><ul><ul><li>No servidor: hellos </li></ul></ul><ul><ul><li>No cliente: helloc </li></ul></ul>

×