Purpose
Indicates why a client Remote Procedure Call (RPC) handle was not created.
Library
C Library (libc.a)
Syntax
#include <rpc/rpc.h>
char *clnt_spcreateerror ( s)
char *s;
Description
The clnt_spcreateerror subroutine returns a string indicating why a client RPC handle was not created.
Parameters
Item | Description |
---|---|
s | Points to a character string that represents the error text. |
Purpose
Returns an error message that is related to the remote procedure call (RPC) client-handle creation.
Library
Network Services Library (libnsl.a)
Syntax
#include <rpc/rpc.h>
char * clnt_spcreateerror( error_msg );
const char *error_msg ;
Description
Parameters
Item | Description |
---|---|
error_msg | Specified an error-message string that is provided by an application. |
Example
In the following example, the clnt_create subroutine tries to register a program number that is not valid and hence returns a null value. The clnt_spcreateerror subroutine returns the actual error message, which is preceded by the specified string ("Invalid Program Number" ) and a colon.
#include <rpc/clnt.h>
#include <stdio.h>
int main()
{
CLIENT *cl;
char hostname[255] ; /* The name of remote host */
char *nettype = "visible" ;
rpcprog_t PROGNUM ; /* Invalid Value */
rpcvers_t PROGVER ;
char *err_str;
cl = clnt_create(hostname, PROGNUM, PROGVER, nettype);
if(cl==NULL)
{
err_str = clnt_spcreateerror("Invalid Program Number ");
printf("\n%s",err_str);
exit(1);
}
/*
* Make a call to clnt_call() subroutine
*/
/* Destroy the client handle at the end */
clnt_destroy(cl);
return 0;
}