CS6223 Distributed Systems Sun RPC
excerpt from : Unix network Programming vol 2: Interprocess Communications by Richard Stevens
These files whose name end in .x are called RPC specification files, and they define the server procedures along with their arguments and results.
0. The server is started and it registers itself with the port mapper on the server host. the client is then started, it it calls clnt_create, which contacts the port mapper on the server host to find the server's ephemeral port. The clnt_create function also establishes a TCP connection with the server.
1.The client calls a local procedure, called the client stub. This procedure was named squareproc_1, and the file containing the client stub was generated by rpcgen and called square_clnt.c
To the client, the client stub appears to be the actual server procedure that it wants to call. The purpose of the stub is to package up the arguments to the remote procedure, possibly put them into some standard format, and then build one or more network messages.
The packaging of the client's argument into a network message is termed marshaling. The client routines and the stub normally call functions in the RPC runtime library (eg., clnt_create in our earlier example).
When link editing under Solaris, these run-time functions are loaded from the -lnsl library, whereas under BSD/OS, they are in the standard C library.
2.These network messages are sent to the remote system by the client stub. This normally requires a system call into the local kernel (eg., write or sendto).
3. The network messages are transferred to the remote system. The typical networking protocols used for this step are either TCP or UDP.
4. A server stub procedure is waiting on the remote system for the client's request. it unmarshals the arguments from the network messages.
5. The server stub executes a local procedure call to invoke the actual server function (our squareproc_1_svc procedure ), passing it the arguments that it received in the network messages from the client.
6. When the server procedure is finished, it returns to the server stub, returning whatever its return values are.
7. The server stub converts the return values, if necessary, and marshals them into one or more network messages to end back to the client.
8. The messages are transfered back across the network to the client.
9. The client stub reads the network messages from the local kernel (eg., read or recvfrom).
10. After possibly converting the return values, the client stub finally returns to the client function. This step appears to be a normal procedure return to the client.
社民連]要求保安局讓民運人士入境 向司徒華逝世致哀3/3 長毛接受記者訪問