Creates a client handle and returns its address. Format #include <rpc/rpc.h> CLIENT *clnt_create(char *host, u_long prognum, u_long versnum, char *protocol);
1 – Arguments
host A pointer to the name of the remote host. prognum The program number associated with the remote procedure. versnum The version number associated with the remote procedure. protocol A pointer to a string containing the name of the protocol for transmitting and receiving RPC messages. Specify either tcp or udp.
2 – Description
The clnt_create routine creates an RPC client handle for prognum. An RPC client handle is a structure containing information about the RPC client. The client can use the UDP or TCP transport protocol. This routine uses the Portmapper. You cannot control the local port. The default sizes of the send and receive buffers are 8800 bytes for the UDP transport, and 4000 bytes for the TCP transport. The retry time for the UDP transport is five seconds. Use the clnt_create routine instead of the callrpc or clnt_ broadcast routines if you want to use one of the following: o The TCP transport o A non-null authentication o More than one active client at the same time You can also use the clnttcp_create routine to use the TCP protocol, or the clntudp_create routine to use the UDP protocol. The clnt_create routine uses the global variable rpc_createerr. rpc_createerr is a structure that contains the most recent service creation error. Use rpc_createerrif you want the client program to handle the error. The value of rpc_createerr is set by any RPC client creation routine that does not succeed. NOTE If the requested program is available on the host but the program does not support the requested version number, this routine still succeeds. A subsequent call to the clnt_call routine will discover the version mismatch. Use the clnt_ create_vers routine if you want to avoid this condition.
3 – Return Values
CLIENT * Client handle containing the server information. NULL Error occurred while creating the client handle. Use the clnt_pcreateerror or clnt_ spcreateerror routine to obtain diagnostic information.