100 likes | 236 Views
Module 9 – RPC Programming. Objectives. RPC Library Interface 에 대해 이해 한다 . High level RPC(Remote Procedure Call) 프로그래밍 기법에 대해 이해한다 . High level RPC 관련 응용 프로그램을 작성한다. High-level & Low-level calls. callrpc() clnt_create() clnttcp_create() clntudp_create() clntraw_create()
E N D
Objectives • RPC Library Interface 에 대해 이해 한다. • High level RPC(Remote Procedure Call) 프로그래밍 기법에 대해 이해한다. • High level RPC 관련 응용 프로그램을 작성한다.
High-level & Low-level calls callrpc() clnt_create() clnttcp_create() clntudp_create() clntraw_create() clnt_destroy() clnt_call() clnt_control() clnt_freeres() high-level calls registerrpc() svc_run() svctcp_create() svcudp_create() svcraw_create() svc_destroy() svc_register() svc_unregister() svc_getargs() svc_sendreply() svc_getreset() Network low-level calls transport library transport library
High-level RPC • high-level function을 이용 • UDP transport protocol 사용 • client & server의 interface를 직접 구현 • Client : server의 함수 호출 • Server : service 함수를 등록 • protocol compiler를 사용하지 않고 프로그램 가능 • TCP를 사용하기 위해서는 low-level function을 사용
High-level RPC Operation Server Machine Server Program service pocedures registerrpc() rpcbind svc_run() dispatch function callrpc() host, program, version, procedure, arguments error or results Client Program Client Machine
High-level functions – server side • registerpc() #include <rpc/rpc.h> int registerrpc(prognum, versnum, procnum, procname, inproc, outproc) u_long prognum, versnum, procnum; char *(*procname)(); xdrproc_t inproc, outproc; • svc_run() #include <rpc/rpc.h> void svc_run()
High-level functions – client side • callrpc() #include <rpc/rpc.h> int callrpc (host, prognum, versnum, procnum, inproc, in, outproc, out) char *host; u_long prognum, versnum, procnum; char *in, *out; xdrproc_t inproc, outproc; • clnt_sperrno() #include <rpc/rpc.h> char *clnt_sperrno(stat) enum clnt_stat stat;
rls.c Client rls.h rls_xdr.c rls_svc.c read_dir.c Server Example Program
rls.h #define DIR_SIZE 8192 /* server program (suite) number */ #define DIRPROG ((u_long) 0x20000001) /* program version number */ #define DIRVERS ((u_long) 1) /* procedure number for look-up */ #define READDIR ((u_long) 1)
rls_xdr.c #include <rpc/rpc.h> #include "rls.h" bool_t xdr_dir(xdrs, objp) XDR *xdrs; char *objp; { return ( xdr_string(xdrs, &objp, DIR_SIZE) ); }