next up previous contents
Next: Tutorials Up: Contents Previous: Server functions

PowerRPC library functions

PowerRPC comes with a runtime library which provides much of the high level RPC functionalities. Here we list the ones which you may want to know about.

void pw_serv_init(void)


A server must call this function first.

void pw_serv_mainloop(SVCXPRT*tcpsvc, SVCXPRT*udpsvc, int dofork, int exitidle)


Parameters:

tcpsvc
A TCP server transport returned from a call to server register function.
udpsvc
A TCP server transport returned from a call to server register function.
dofork
If true, then the server would fork a dedicated child server for each client.
exitidle
Should always be 1.

void pw_serv_once(struct timeval *timeout)


Parameters:

timeout
A time out value.

Ask the server which is not started by pw_serv_mainloop() to serve pending RPC calls. If there is no pending calls, it waits for calls during the time period specified by timeout parameter.

The call returns after pending calls have been done, or timeout expires.

void pw_serv_async_enable(void)


Enables an asynchronous server. Instead of waiting for requests, the server is signaled when calls arrive.

void pw_serv_async_disable(void) gif


Disable the asynchronous server previous enabled.

void pw_free_reference(xdrproc_t xdrfunc, void* ptr, u_int size)


Parameters:

xdrfunc
An XDR function.
ptr
A pointer to memory allocated by the XDR function.
size
The size of the memory block.

Sometime, the underlying RPC mechanism allocates memory, a typical example is when an RPC function return a pointer. To free this memory, one needs to call this function. As in the following code segment,

        T * pT;
        pT  = foo() ; /* foo() is an RPC */

        ...

        /*free it */
        pw_free_reference(xdr_T, pT, sizeof(*pT);

void pw_serialize(FILE*fp, xdrproc_t xdrfunc, void* pdata, enum xdr_op op)


Parameters:

fp
A opened FILE pointer.
xdrfunc
An XDR function.
pdata
A pointer to data.
op
XDR operation, can be XDR_ENCODE or XDR_DECODE.

This function can be used to serialize/deserialize a C data structure to a file in a platform independent format. When op is XDR_ENCODE data is serialized to the file, when op is XDR_DECODE data is read from the file and the data structure is reconstructed in memory.

Tutorials


next up previous contents
Next: Tutorials Up: Contents Previous: Server functions

Copyright (C) Netbula LLC, 1996