Purpose
Changes or retrieves various information about a client object.
Library
C Library (libc.a)
Syntax
Description
The clnt_control macro is used to change or retrieve various information about a client object.
User Datagram Protocol (UDP) and Transmission Control Protocol (TCP) have the following supported values for the req parameter's argument types and functions:
Values for the req Parameter | Argument Type | Function |
---|---|---|
CLSET_TIMEOUT | struct timeval | Sets total time out. |
CLGET_TIMEOUT | struct timeval | Gets total time out. |
CLGET_SERVER_ADDR | struct sockaddr | Gets server's address. |
The following operations are valid for UDP only:
Values for the req Parameter | Argument Type | Function |
---|---|---|
CLSET_RETRY_TIMEOUT | struct timeval | Sets the retry time out. |
CLGET_RETRY_TIMEOUT | struct timeval | Gets the retry time out. |
Parameters
Item | Description |
---|---|
cl | Points to the structure of the client handle. |
req | Indicates the type of operation. |
info | Points to the information for request type. |
Return Values
Upon successful completion, this subroutine returns a value of 1. If unsuccessful, it returns a value of 0.
Purpose
Changes or retrieves information of the client handle.
Library
Network Services Library (libnsl.a)
Syntax
Description
For the req parameter in the example, the value of the info parameter is of the rpcvers_t type.
Values for the req Parameter | Argument Type | Function |
---|---|---|
CLSET_TIMEOUT | struct timeval * | Sets the total timeout. |
CLGET_TIMEOUT | struct timeval * | Gets the total timeout. |
CLGET_SVC_ADDR | struct netbuf * | Gets the address of the server. |
CLGET_FD | int * | Gets associated file descriptor. |
CLSET_RETRY_TIMEOUT | struct timeval * | Sets the retry timeout. |
CLGET_RETRY_TIMEOUT | struct timeval * | Gets the retry timeout. |
CLGET_VERS | rpcvers_t | Gets the version number of the RPC program. |
CLSET_VERS | rpcvers_t | Sets the version number of the RPC program. |
CLGET_XID | uint32_t | Gets XID of the previous RPC. |
CLSET_XID | uint32_t | Sets XID of the previous RPC. |
CLGET_PROG | rpcprog_t | Gets the program number. |
CLSET_PROG | rpcprog_t | Sets the program number. |
Parameters
Item | Description |
---|---|
cl | Points to the structure of the generic RPC-client handle . |
req | Indicates the type of the operation. |
info | Points to the information for request type. The info parameter is expected to be a pointer to an appropriate structure. The nature of the structure depends on the type of the operation. |
Return Values
Item | Description |
---|---|
1 | successful |
0 | unsuccessful |
Examples
In the following example, the clnt_control macro subroutine returns the version number of the program that is specified by the versnum parameter.
#include <stdlib.h>
#include <rpc/rpc.h>
int main()
{
struct timeval t;
CLIENT *cl ;
rpcprog_t PROG = 0x3fffffffL;
rpcvers_t versnum,PROGVER = 0x1L;
char hostname[255] /* The Remote Host */
char *nettype = "visible" ;
/* Create generic client handle */
cl = clnt_create( hostname, PROG, PROGVER, nettype);
if(cl==NULL)
{
fprintf(stderr,"Couldnot create client handle");
exit(1);
}
if(!clnt_control(cl, CLGET_VERS, versnum))
{
fprintf(stderr,"Failed in clnt_control routine");
exit(1);
}
fprintf(stdout,"\n VERSION NUMBER = %lu \n", versnum);
/* Destroy the client handle at the end */
clnt_destroy(cl);
return 0;
}