Changes or retrieves information of global remote procedure call (RPC) attributes for client and server applications.
Network Services Library (libnsl.a)
For the op parameter in this example, the value of the info parameter is of the int * type.
Values for the op Parameter | Argument Type | Function |
---|---|---|
RPC_SVC_MTMODE_SET | int * | Sets the multithread mode. |
RPC_SVC_MTMODE_GET | int * | Gets the multithread mode. |
RPC_SVC_THRMAX_SET | int * | Sets the maximum number of threads. |
RPC_SVC_THRMAX_GET | int * | Gets the maximum number of threads. |
RPC_SVC_THRTOTAL_GET | int * | Gets the number of active threads. |
RPC_SVC_THRCREATES_GET | int * | Gets the number of threads created. |
RPC_SVC_THRERRORS_GET | int * | Gets the number of threads that create errors. |
RPC_SVC_USE_POLLFD | int * | Sets the number of file descriptors to unlimited. |
Item | Description |
---|---|
RPC_SVC_MT_NONE | the single-threaded mode (default) |
RPC_SVC_MT_AUTO | the automatic MT mode |
RPC_SVC_MT_USER | the user MT mode |
Item | Description |
---|---|
op | Represents the operation type. |
info | Points to the information for the request type. The info parameter is expected to be a pointer to an appropriate structure. The nature of the structure depends on the operation type. |
Item | Description |
---|---|
TRUE | successful |
FALSE | unsuccessful |
In the following example, the rpc_control subroutine is used to set server program in the automatic MT mode.
#include <stdlib.h>
#include <rpc/rpc.h>
int main()
{
SVCXPRT *transpnum;
rpcprog_t prognum = 0x3fffffffL;
rpcvers_t progver = 0x1L;
/* Register the service for prognum & progver on tcp transport */
transpnum = svc_create(dispatch_AUTOMT, prognum, progver, "tcp");
if (transpnum == 0)
{
fprintf(stderr, "Cannot create a service.\n");
svc_unreg(prognum,progver);
exit(1);
}
/* Configure the server in AUTO_MT mode */
mode = RPC_SVC_MT_AUTO;
if(rpc_control(RPC_SVC_MTMODE_SET,&mode) == FALSE)
{
fprintf(stderr,"\nError in rpc_control!\n");
exit(1);
}
svc_run();
return 0;
}