Server Side of the Bottom-Level Interface
The following code example is an example of creating a bottom-level server.
Example 4-15 Server for Bottom Level
Server Caching
svc_dg_enablecache() initiates service caching for datagram transports. Caching should be used only in cases where a server procedure is a "once only" kind of operation. Executing a cached server procedure multiple times yields different results.
svc_dg_enablecache(xprt, cache_size) SVCXPRT *xprt; unsigned int cache_size; |
This function allocates a duplicate request cache for the service endpoint xprt, large enough to hold cache_size entries. A duplicate request cache is needed if the service contains procedures with varying results. After caching is enabled, it cannot be disabled.
Low-Level Data Structures
The following data structure information is for reference only. The implementation might change.
The first structure is the client RPC handle, defined in <rpc/clnt.h>. Low-level implementations must provide and initialize one handle per connection, as shown in the following code example.
Example 4-16 RPC Client Handle Structure
The first field of the client-side handle is an authentication structure, defined in <rpc/auth.h>. By default, this field is set to AUTH_NONE. A client program must initialize cl_auth appropriately, as shown in the following code example.
Example 4-17 Client Authentication Handle
In the AUTH structure, ah_cred contains the caller's credentials, and ah_verf contains the data to verify the credentials. See "Authentication" for details.
The following code example shows the server transport handle.
Example 4-18 Server Transport Handle
The following table shows the fields for the server transport handle.
xp_fd | The file descriptor associated with the handle. Two or more server handles can share the same file descriptor. |
xp_netid | The network identifier (for example, udp) of the transport on which the handle is created and xp_tp is the device name associated with that transport. |
xp_ltaddr | The server's own bind address. |
xp_rtaddr | The address of the remote caller (and so can change from call to call). |
xp_netid xp_tp xp_ltaddr | Initialized by svc_tli_create() and other expert-level routines. |
The rest of the fields are initialized by the bottom-level server routines svc_dg_create() and svc_vc_create().
For connection-oriented endpoints, the following fields are not valid until a connection has been requested and accepted for the server:
- xp_fd
- xp_ops()
- xp_p1()
- xp_p2
- xp_verf()
- xp_tp()
- xp_ltaddr
- xp_rtaddr()
- xp_netid()