1 / 10

Invocação Remota de Procedimentos (RPC)

Invocação Remota de Procedimentos (RPC). Alexandre Bragança 2001 DEI / ISEP. Modelo de Programação. Cliente-Servidor. Funcionamento. OSF DCE. DCE = Distributed Computing Environment OSF = Open Software Foundation. Exemplo Hello World. /* file hellop.c */ #include <stdio.h>

bunny
Download Presentation

Invocação Remota de Procedimentos (RPC)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Invocação Remota de Procedimentos (RPC) Alexandre Bragança 2001 DEI / ISEP

  2. Modelo de Programação

  3. Cliente-Servidor

  4. Funcionamento

  5. OSF DCE • DCE = Distributed Computing Environment • OSF = Open Software Foundation

  6. Exemplo Hello World /* file hellop.c */ #include <stdio.h> void HelloProc(unsigned char * pszString) { printf(“%s\n”, pszString); } /* file: hello.c, a stand-alone application */ #include “hellop.c” void main(void) { unsigned Char * pszString = “Hello, World”; HelloProc(pszString); }

  7. Definição do Interface • //file hello.idl • [ • uuid(7a98c250-6808-11cf-b73b-00aa00b677a7), • version(1.0) • ] • interface hello • { • void HelloProc([in, string] unsigned char * pszString); • void Shutdown(void); • } • A função Shutdown permite que o cliente ‘desligue’ o servidor

  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. Implementação do código do Servidor #include <stdlib.h> #include <stdio.h> #include "hello.h" // header file generated by MIDL compiler void HelloProc(unsigned char * pszString) { printf("%s\n", pszString); } void Shutdown(void) { RPC_STATUS status; printf("Calling RpcMgmtStopServerListening\n"); status = RpcMgmtStopServerListening(NULL); printf("RpcMgmtStopServerListening returned: 0x%x\n", status); if (status) { exit(status); } printf("Calling RpcServerUnregisterIf\n"); status = RpcServerUnregisterIf(NULL, NULL, FALSE); printf("RpcServerUnregisterIf returned 0x%x\n", status); if (status) { exit(status); } }

  10. Compilação & Execução • Compilação • Cliente: helloc.exe • helloc.c - Código do cliente • hello_c.c– Stub • Servidor: hellos.exe • hellos.c – Código do servidor • hellop.c – Implementação dos serviços • hello_s.c – Stub do servidor • Execução • No servidor: hellos • No cliente: helloc

More Related