Donnerstag, 24. Februar 2011

CS6223 Distributed Systems :RPC --client handle : Clnt_create()

CS6223 Distributed Systems :RPC --client handle : Clnt_create()

excerpted from Richard Stevens --Unix network programming volume 2: Interprocess Communications (2 ed.), ch. 16, page 402-404.

assignment :
Client handles are intended to look like standard I/O FILE pointers ( hence the uppercase name of CLIENT)


. . .

cl = Clnt_create (argv[1], SQUARE_PROG, SQUARE_VERS, "tcp");

. . .

1. The first argument to clnt_create is either the hostname or IP address of the host running our server.

2. The second argument is the program name.

3. The third argument is the version number, both from the square.x file.

4. The final argument is our choice of protocol.

5. How to compile on the client side:

rpcgen -C square.x
cc -c client.c -o client.o
cc -c square_clnt.c -o square_clnt.o
cc -c square_xde.c -o square_xdr.o
cc -o client client.o square_clnt.o square_xdr.o libunpic.a -lnsl

The -C option to rpcgen tells it to generate ANSI C prototypes in the square.h header.

rpcgen also generates a client stub ( square_clnt.c ) and a file named square_xdr.c that handles the XDR data conversion.

6. How to compile on the server side:

cc -c server.c -o server.o
cc -c square_svc.c -o square_svc.o
cc -o server server.o square_svc.o square_xdr.o libunpipc.a -lnsl

96. 在我看來,香港一直在生活中實踐作家傑克‧倫敦(Jack LONDON)的信條:

“ 寧化飛灰,不作浮塵。
“ 寧投熊熊烈火,光盡而滅;
“ 不伴寂寂朽木,默然同腐。
“ 寧為耀目流星,迸發萬丈光芒;
“ 不羨永恒星體,悠悠沉睡終古。”

97. 前路不管有何挑戰,都不會,我重複,都不會使這顆流星飛墜,光華從此消逝。我深願香港能奮然而起,征服未來,那時候,歷史也必為之動容,起立喝采。

Keine Kommentare: