As shown in the previous examples, property definitions come in two places: immediately enclosed in the ``body" of an interface declaration, or inside the ``body" of a function declaration.
The following properties can be defined.
VERSION
An integer value to specified version number for the interface.
The default value is 1.
TRANSPORT_PROTOCOL
The protocol used by client/server for communications. Choices are
The default is tcp_and_udp.
SERVER_PORT
An integer value used to specify to the port number of the RPC server. When this property is not set (the usual case), the server choose an arbitrary port that is available and the client consults the portmapper on the server host to obtain the port number. When this set, the client will bypass the portmapper and uses the port number specified.
NO_PMAP_REGISTER
When this property is set to true, the server will skip registration with the portmapper. The rpcinfo command won't find your server. You would normally set this property when you also specified a fixed port.
The default is false.
INIT_BEFORE_REGISTER
A user defined function to be called before server register itself. This function must be of the type of void (*) (int, char**), it is passed the argc and argv arguments from the main(int argc, char**argv) function.
No default value for this property.
INIT_AFTER_REGISTER
The user defined function to be called after server register itself. This function will be passed the argc and argv arguments from the main(int argc, char**argv) function.
For example, you could use this initialization function to set up signal handlers, a useful one is to unregister your RPC server with the portmapper when a SIGINT is received. Using the quote RPC server as an example, we can write the following functions,
void handler(int sig) { quote_1_unmap(0,0); exit(0); } void set_sigint_handler(int argc, char**argv) { signal(SIGINT, handler); }where quote_1_unmap() is a function generated by powerRPC for the purpose of unsetting the portmapper entry of the quote server. By setting
INIT_AFTER_REGISTER = set_sigint_handler;you make sure that the quote server will remove its entry from the portmapper's database.
No default value for this property.
GEN_MAIN_FUNC
When set to false, the powerRPC compiler will not generate the main() function for the server.
The default is true.
FORK_ON_CONNECTION
When set to true, the RPC server will fork a dedicated server for each client, all RPCes from the client will be handled by the child. For TCP, the child is created when a request for connection is received, when the client detaches from the server, the forked child will exit. The semantics with UDP transport is different, since UDP is not connection oriented. For UDP, the server would fork to handle each incoming RPC call. It is recommended not to use this option with UDP transport, use FORK_ON_CALL instead.
The default is false.
FORK_ON_CALL
When set to true for an RPC function, the server will fork a child to handle the call, so itself can still handle other requests.
The forked child will exit at the completion of the call.
The default is false.
NON_BLOCKING
When this is set to true for an RPC function, the server will reply to the server immediately, before it actually calls the user implementation of the function.
Obviously, the return type of such an RPC function should be void and it should have no out or inout arguments.
TIMEOUT_VALUE
This is an integral value for the RPC timeout in seconds on the client side. When specified for an RPC function, a timeout error will occur when a reply for this function is not received within the timeout.
For example, if you set this to be 0 for function foo(), then every call of foo() will timeout.
The default value is 60.
SERV_CALL_PREFIX
For an RPC function foo() , the powerRPC compiler will generate the client definition of foo() for you, and you must write the server implementation of foo() yourself. However, sometimes, you want to make a program both a server and a client of the same RPC interface. To make this possible, you must set this property.
For example, when you set
property SERV_CALL_PREFIX = serv_ ;powerRPC expects your sever implementation of foo() to be serv_foo(). This solve the name conflict and you can write a program that is both a server and also a client (of another server) of the same RPC.